Stefan Pranger
2 years ago
commit
c4ead2998f
39 changed files with 742 additions and 0 deletions
-
12001.vpm
-
16002.vpm
-
21003.vpm
-
28004.vpm
-
17005.vpm
-
25006.vpm
-
17007.vpm
-
17008.vpm
-
22009.vpm
-
25010.vpm
-
19011.vpm
-
20013.vpm
-
16014.vpm
-
15015.vpm
-
20016.vpm
-
21017.vpm
-
17020.vpm
-
19023.vpm
-
22024.vpm
-
20025.vpm
-
18026.vpm
-
22027.vpm
-
18030.vpm
-
22040.vpm
-
18041.vpm
-
20042.vpm
-
22043.vpm
-
15044.vpm
-
12046.vpm
-
17050.vpm
-
19051.vpm
-
30052.vpm
-
15053.vpm
-
22054.vpm
-
12070.vpm
-
14071.vpm
-
20072.vpm
-
15073.vpm
-
22090.vpm
@ -0,0 +1,12 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸╻╺┳╸ ╻ ╻┏━┓┏━┓╻┏ ┏━┓╻ ╻┏━┓┏━┓ |
||||
|
┃╺┓┃ ┃ ╺━╸ ┃╻┃┃ ┃┣┳┛┣┻┓┗━┓┣━┫┃ ┃┣━┛ |
||||
|
┗━┛╹ ╹ ┗┻┛┗━┛╹┗╸╹ ╹┗━┛╹ ╹┗━┛╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
27. September 2022 |
||||
|
Pranger Stefan |
||||
|
|
@ -0,0 +1,16 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━┓┏━┓┏━┓╺┳┓┏┳┓┏━┓┏━┓ |
||||
|
┣┳┛┃ ┃┣━┫ ┃┃┃┃┃┣━┫┣━┛ |
||||
|
╹┗╸┗━┛╹ ╹╺┻┛╹ ╹╹ ╹╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
- git basics, what is git capable of |
||||
|
- what do to in what situations |
||||
|
- project management |
||||
|
- pull requests and feature branches |
||||
|
- bug tracking |
||||
|
- continuous integration |
||||
|
- git gadgets (grep, bisect, etc.) |
@ -0,0 +1,21 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏┳┓┏━┓╻┏┓╻ ┏━┓┏━┓╻┏┓╻╺┳╸┏━┓ |
||||
|
┃┃┃┣━┫┃┃┗┫ ┣━┛┃ ┃┃┃┗┫ ┃ ┗━┓ |
||||
|
╹ ╹╹ ╹╹╹ ╹ ╹ ┗━┛╹╹ ╹ ╹ ┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
- Staging Area and |
||||
|
- Interactive Rebasing for well crafted commits, |
||||
|
|
||||
|
- Merging and Rebasing, |
||||
|
|
||||
|
- Pull Request workflow and |
||||
|
|
||||
|
- Git as inspection tool. |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,28 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸╻╺┳╸ ┏┓ ┏━┓┏━┓╻┏━╸┏━┓ |
||||
|
┃╺┓┃ ┃ ┣┻┓┣━┫┗━┓┃┃ ┗━┓ |
||||
|
┗━┛╹ ╹ ┗━┛╹ ╹┗━┛╹┗━╸┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
- _distributed_ version control |
||||
|
- staging area |
||||
|
- git add, git reset, etc. instead of only commiting |
||||
|
- branching |
||||
|
- "killer feature" |
||||
|
- content-addressable filesystem |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,17 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸╻╺┳╸ ╻┏┓╻╻╺┳╸ |
||||
|
┃╺┓┃ ┃ ┃┃┗┫┃ ┃ |
||||
|
┗━┛╹ ╹ ╹╹ ╹╹ ╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
Create or clone a repository via |
||||
|
- $ git init |
||||
|
- $ git clone |
||||
|
|
||||
|
Basic configuration: |
||||
|
- $ git config --global user.name "Foo Bar" |
||||
|
- $ git config --global user.email foobar@example.com |
||||
|
|
@ -0,0 +1,25 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━┓╺┳╸┏━┓┏━╸╻┏┓╻┏━╸ ┏━┓┏━┓┏━╸┏━┓ |
||||
|
┗━┓ ┃ ┣━┫┃╺┓┃┃┗┫┃╺┓ ┣━┫┣┳┛┣╸ ┣━┫ |
||||
|
┗━┛ ╹ ╹ ╹┗━┛╹╹ ╹┗━┛ ╹ ╹╹┗╸┗━╸╹ ╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
- first main difference to SVN |
||||
|
- advantage of git |
||||
|
|
||||
|
Files can be: |
||||
|
|
||||
|
┌─────────┐ ┌──────────┐ ┌────────┐ ┌──────┐ ┌────────┐ |
||||
|
│Untracked│ │Unmodified│ │Modified│ │Staged│ │Commited│ |
||||
|
└─────────┘ └──────────┘ └────────┘ └──────┘ └────────┘ |
||||
|
|
||||
|
Git manages these states as: |
||||
|
|
||||
|
┌─────────────────┐ ┌─────┐ ┌────┐ |
||||
|
│Working Directory│ │Index│ │HEAD│ |
||||
|
└─────────────────┘ └─────┘ └────┘ |
||||
|
Your Sandbox The proposed The next |
||||
|
next commit parent |
@ -0,0 +1,17 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━┓╺┳╸┏━┓┏━╸╻┏┓╻┏━╸ ┏━┓┏━┓┏━╸┏━┓ |
||||
|
┗━┓ ┃ ┣━┫┃╺┓┃┃┗┫┃╺┓ ┣━┫┣┳┛┣╸ ┣━┫ |
||||
|
┗━┛ ╹ ╹ ╹┗━┛╹╹ ╹┗━┛ ╹ ╹╹┗╸┗━╸╹ ╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
- git add |
||||
|
- git add --patch (-p) |
||||
|
- add individual lines (hunks) to commits |
||||
|
- "interactive staging" |
||||
|
- very useful to craft commits that are easy to understand |
||||
|
- git restore --staged/--worktree |
||||
|
- git reset --soft/--mixed/--hard |
||||
|
- git rm --cached |
@ -0,0 +1,17 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━┓╺┳╸┏━┓┏━╸╻┏┓╻┏━╸ ┏━┓┏━┓┏━╸┏━┓ |
||||
|
┗━┓ ┃ ┣━┫┃╺┓┃┃┗┫┃╺┓ ┣━┫┣┳┛┣╸ ┣━┫ |
||||
|
┗━┛ ╹ ╹ ╹┗━┛╹╹ ╹┗━┛ ╹ ╹╹┗╸┗━╸╹ ╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
Check your modifications or what you are about to commit |
||||
|
- git diff / git diff --staged |
||||
|
|
||||
|
Should help to have a clean process of commiting changes |
||||
|
Finalizing step: git commit |
||||
|
|
||||
|
What if I messed up my current commit? |
||||
|
- $ git commit --amend |
@ -0,0 +1,22 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸╻╺┳╸ ┏━┓┏┓ ┏┓┏━╸┏━╸╺┳╸┏━┓ |
||||
|
┃╺┓┃ ┃ ┃ ┃┣┻┓ ┃┣╸ ┃ ┃ ┗━┓ |
||||
|
┗━┛╹ ╹ ┗━┛┗━┛┗━┛┗━╸┗━╸ ╹ ┗━┛ |
||||
|
|
||||
|
┌────────────────┐ ┌──────────────────────┐main.c┌────┐ |
||||
|
│commit (b3aacfe)│───>│tree (think directory)│─────>│blob│ |
||||
|
└────────────────┘ └──────────────────────┘ └────┘ |
||||
|
| parent \ |
||||
|
v \ |
||||
|
┌────────────────┐ ┌──────────────────────┐ \ |
||||
|
┌──>│commit (a21fh1a)│───>│ tree │ \ |
||||
|
| └────────────────┘ └──────────────────────┘ \ |
||||
|
┌───┐ / | \ \ |
||||
|
│tag│ main.c config.h main.h \ |
||||
|
└───┘ / | \ \ |
||||
|
┌────┐ ┌────┐ ┌────┐<--° |
||||
|
│blob│ │blob│<-┐ │blob│ | |
||||
|
└────┘ └────┘ \ └────┘ | |
||||
|
└───────────┘ |
@ -0,0 +1,25 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━┓┏━╸╻ ╻╻┏━┓╻┏━┓┏┓╻ ┏━┓┏━╸╻ ┏━╸┏━╸╺┳╸╻┏━┓┏┓╻ |
||||
|
┣┳┛┣╸ ┃┏┛┃┗━┓┃┃ ┃┃┗┫ ┗━┓┣╸ ┃ ┣╸ ┃ ┃ ┃┃ ┃┃┗┫ |
||||
|
╹┗╸┗━╸┗┛ ╹┗━┛╹┗━┛╹ ╹ ┗━┛┗━╸┗━╸┗━╸┗━╸ ╹ ╹┗━┛╹ ╹ |
||||
|
|
||||
|
┌────────────────┐ |
||||
|
│commit (b3aacfe)│ |
||||
|
└────────────────┘ |
||||
|
|
||||
|
- $ git show <commit-ish> -- <glob-pattern> |
||||
|
|
||||
|
- commits are referencable via |
||||
|
- their SHA1 |
||||
|
- HEAD |
||||
|
- tags/branchnames |
||||
|
|
||||
|
- Syntax: |
||||
|
- HEAD~<n> // select the n-th ancestor of HEAD |
||||
|
- <commit-ish>..<commit-ish> |
||||
|
|
||||
|
- HEAD-history: |
||||
|
- HEAD@{<n>} |
||||
|
|
@ -0,0 +1,19 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏┓ ┏━┓┏━┓┏┓╻┏━╸╻ ╻╻┏┓╻┏━╸ |
||||
|
┣┻┓┣┳┛┣━┫┃┗┫┃ ┣━┫┃┃┗┫┃╺┓ |
||||
|
┗━┛╹┗╸╹ ╹╹ ╹┗━╸╹ ╹╹╹ ╹┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
- git's "killer feature" |
||||
|
|
||||
|
- A new branch is essentially just opening a new history |
||||
|
(i.e. no copying involved!) |
||||
|
|
||||
|
- Highly encouraged to use many (shortlived) branches |
||||
|
|
||||
|
Create a new branch with |
||||
|
- $ git switch --create/-c <branch-name> |
||||
|
|
@ -0,0 +1,20 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏┓ ┏━┓┏━┓┏┓╻┏━╸╻ ╻╻┏┓╻┏━╸ |
||||
|
┣┻┓┣┳┛┣━┫┃┗┫┃ ┣━┫┃┃┗┫┃╺┓ |
||||
|
┗━┛╹┗╸╹ ╹╹ ╹┗━╸╹ ╹╹╹ ╹┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
Switching between branches with |
||||
|
- $ git switch <branch-name> |
||||
|
- $ git switch - |
||||
|
|
||||
|
Cannot switch if that would overwrite modifications |
||||
|
|
||||
|
Untracked files will simply "move along" |
||||
|
|
||||
|
Delete or rename a branch: |
||||
|
- $ git branch -d <branch-name> |
||||
|
- $ git branch -m <oldbranch> <newbranch> |
@ -0,0 +1,16 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸╻╺┳╸ ┏━┓╺┳╸┏━┓┏━┓╻ ╻ |
||||
|
┃╺┓┃ ┃ ┗━┓ ┃ ┣━┫┗━┓┣━┫ |
||||
|
┗━┛╹ ╹ ┗━┛ ╹ ╹ ╹┗━┛╹ ╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
Very helpful to quickly safe modifications |
||||
|
|
||||
|
- $ git stash push --message/-m "..." |
||||
|
- $ git stash list |
||||
|
- $ git stash apply/pop |
||||
|
|
||||
|
|
@ -0,0 +1,15 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸╻╺┳╸ ┏━┓╺┳╸┏━┓┏━┓╻ ╻ |
||||
|
┃╺┓┃ ┃ ┗━┓ ┃ ┣━┫┗━┓┣━┫ |
||||
|
┗━┛╹ ╹ ┗━┛ ╹ ╹ ╹┗━┛╹ ╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
$ git stash push -m "WIP some frontend feature" |
||||
|
$ git switch stable |
||||
|
... |
||||
|
$ git commit |
||||
|
$ git switch frontend_feature |
||||
|
$ git stash pop |
@ -0,0 +1,20 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
╻┏┓╻╺┳╸┏━╸┏━┓┏━┓┏━╸╺┳╸╻╻ ╻┏━╸ ┏━┓┏━╸┏┓ ┏━┓┏━┓╻┏┓╻┏━╸ |
||||
|
┃┃┗┫ ┃ ┣╸ ┣┳┛┣━┫┃ ┃ ┃┃┏┛┣╸ ┣┳┛┣╸ ┣┻┓┣━┫┗━┓┃┃┗┫┃╺┓ |
||||
|
╹╹ ╹ ╹ ┗━╸╹┗╸╹ ╹┗━╸ ╹ ╹┗┛ ┗━╸ ╹┗╸┗━╸┗━┛╹ ╹┗━┛╹╹ ╹┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
- $ git rebase -i <commit-ish> |
||||
|
|
||||
|
Can be used to cleanup commit history |
||||
|
|
||||
|
- allows to basically change the history of your commits |
||||
|
- each project should have a guideline |
||||
|
- small feature may for example be _squashed_ together |
||||
|
- WIP- or unnecessary commits can be removed |
||||
|
- remove _checkpoint commits_ |
||||
|
-> $ git rebase -i my_current_feature@{24.hours.ago}~1 |
||||
|
|
@ -0,0 +1,21 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
╻┏┓╻╺┳╸┏━╸┏━┓┏━┓┏━╸╺┳╸╻╻ ╻┏━╸ ┏━┓┏━╸┏┓ ┏━┓┏━┓╻┏┓╻┏━╸ |
||||
|
┃┃┗┫ ┃ ┣╸ ┣┳┛┣━┫┃ ┃ ┃┃┏┛┣╸ ┣┳┛┣╸ ┣┻┓┣━┫┗━┓┃┃┗┫┃╺┓ |
||||
|
╹╹ ╹ ╹ ┗━╸╹┗╸╹ ╹┗━╸ ╹ ╹┗┛ ┗━╸ ╹┗╸┗━╸┗━┛╹ ╹┗━┛╹╹ ╹┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
# Commands: |
||||
|
# p, pick <commit> = use commit |
||||
|
# r, reword <commit> = use commit, but edit the commit message |
||||
|
# e, edit <commit> = use commit, but stop for amending |
||||
|
# s, squash <commit> = use commit, but meld into previous commit |
||||
|
# f, fixup <commit> = like "squash", but discard this commit's log message |
||||
|
... |
||||
|
# |
||||
|
# These lines can be re-ordered; they are executed from top to bottom. |
||||
|
# |
||||
|
# If you remove a line here THAT COMMIT WILL BE LOST. |
||||
|
|
@ -0,0 +1,17 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━┓┏━╸┏┳┓┏━┓╺┳╸┏━╸┏━┓ |
||||
|
┣┳┛┣╸ ┃┃┃┃ ┃ ┃ ┣╸ ┗━┓ |
||||
|
╹┗╸┗━╸╹ ╹┗━┛ ╹ ┗━╸┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
Remote server to share code base |
||||
|
|
||||
|
- Gets setup with $ git clone |
||||
|
- $ git remote add <name> <url> |
||||
|
|
||||
|
- $ git fetch |
||||
|
- $ git pull <remote> <branch> |
||||
|
- $ git push <remote> <branch> |
@ -0,0 +1,19 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏┳┓┏━╸┏━┓┏━╸╻┏┓╻┏━╸ |
||||
|
┃┃┃┣╸ ┣┳┛┃╺┓┃┃┗┫┃╺┓ |
||||
|
╹ ╹┗━╸╹┗╸┗━┛╹╹ ╹┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
Multiple parallel workflows are encouraged |
||||
|
-> unavoidable conflicts |
||||
|
|
||||
|
- Project guideline on how to handle conflicts |
||||
|
|
||||
|
- For more advanced usage: |
||||
|
- $ git rerere |
||||
|
- different merging strategies |
||||
|
|
||||
|
|
@ -0,0 +1,22 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏┳┓┏━╸┏━┓┏━╸╻┏┓╻┏━╸ ┏━╸┏━╸ |
||||
|
┃┃┃┣╸ ┣┳┛┃╺┓┃┃┗┫┃╺┓ ╺━╸ ┣╸ ┣╸ |
||||
|
╹ ╹┗━╸╹┗╸┗━┛╹╹ ╹┗━┛ ╹ ╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
- _fast-forward_ merge possible if HEAD direct ancestor |
||||
|
- This allows for a clean, linear history on stable branches |
||||
|
- helps with git blame, git bisect, git rebase -i |
||||
|
|
||||
|
┌─────────────────────────────────────────────────────────────┐ |
||||
|
│[spranger@gitWorkshop/stagingArea] git merge more_int_changes│ |
||||
|
│Updating eff74ed..a2c365a │ |
||||
|
│Fast-forward │ |
||||
|
│ testfile1 | 4 ++-- │ |
||||
|
│ 1 file changed, 2 insertions(+), 2 deletions(-) │ |
||||
|
└─────────────────────────────────────────────────────────────┘ |
||||
|
|
||||
|
- --ff, --no-ff, --ff-only |
@ -0,0 +1,20 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━┓┏━╸┏┓ ┏━┓┏━┓╻┏┓╻┏━╸ |
||||
|
┣┳┛┣╸ ┣┻┓┣━┫┗━┓┃┃┗┫┃╺┓ |
||||
|
╹┗╸┗━╸┗━┛╹ ╹┗━┛╹╹ ╹┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
Allows to move bases of branches (and more) |
||||
|
|
||||
|
- Most common usage: Update the base of your branch if outdated |
||||
|
- Common strategy to _always_ ensure fast-forward merges |
||||
|
- Very helpful in complicated branching settings |
||||
|
|
||||
|
Important Note: |
||||
|
┌─────────────────────────────────────────────────────────┐ |
||||
|
│Do not rebase commits that exist outside your repository │ |
||||
|
│ and that people (may) have based work on. │ |
||||
|
└─────────────────────────────────────────────────────────┘ |
@ -0,0 +1,18 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸┏━┓┏┓╻┏━╸╻ ╻┏━╸╺┳╸┏━┓ |
||||
|
┃ ┃ ┃┃┗┫┣╸ ┃ ┃┃ ┃ ┗━┓ |
||||
|
┗━╸┗━┛╹ ╹╹ ┗━╸╹┗━╸ ╹ ┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
Git tracks (per hunk-) conflicts over three files: |
||||
|
- base/common |
||||
|
- ours |
||||
|
- theirs |
||||
|
|
||||
|
- $ git config --global merge.conflictstyle diff3 |
||||
|
- Often helpful to have common state |
||||
|
|
||||
|
|
@ -0,0 +1,22 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸┏━┓┏┓╻┏━╸╻ ╻┏━╸╺┳╸┏━┓ |
||||
|
┃ ┃ ┃┃┗┫┣╸ ┃ ┃┃ ┃ ┗━┓ |
||||
|
┗━╸┗━┛╹ ╹╹ ┗━╸╹┗━╸ ╹ ┗━┛ |
||||
|
|
||||
|
┌────────────────────────┐ ┌────────────────────────┐ |
||||
|
│ #include <algorithms> │ │ int main() { │ |
||||
|
│ <<<<<<< HEAD │ │ int a = 5; │ |
||||
|
│ #include <sstream> │ │ <<<<<<< HEAD │ |
||||
|
│ ||||||| 9275968 │ │ int b = 4; │ |
||||
|
│ ======= │ │ ||||||| 9275968 │ |
||||
|
│ #include <string> │ │ int b = 8; │ |
||||
|
│>>>>>>> new_feature │ │ ======= │ |
||||
|
└────────────────────────┘ │ int b = 9; │ |
||||
|
│ >>>>>>> new_feature │ |
||||
|
└────────────────────────┘ |
||||
|
- Conflict markers appear in the file itself |
||||
|
- Simplest way to handle: |
||||
|
-> directly modify the file |
||||
|
- Git difftool for visual conflict resolving |
@ -0,0 +1,18 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
╺┳╸┏━╸┏━┓┏┳┓ ╻ ╻┏━┓┏━┓╻┏ ┏━╸╻ ┏━┓╻ ╻┏━┓ |
||||
|
┃ ┣╸ ┣━┫┃┃┃ ┃╻┃┃ ┃┣┳┛┣┻┓┣╸ ┃ ┃ ┃┃╻┃┗━┓ |
||||
|
╹ ┗━╸╹ ╹╹ ╹ ┗┻┛┗━┛╹┗╸╹ ╹╹ ┗━╸┗━┛┗┻┛┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
Team Workflows: |
||||
|
- Merge vs. Rebase |
||||
|
- Only fast-forward? |
||||
|
- Keep merge commits? |
||||
|
|
||||
|
Branching Strategies: |
||||
|
- Main - Development - Feature branches - Stable branches |
||||
|
- Main - Feature branches |
||||
|
- etc. |
@ -0,0 +1,22 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸┏━┓╻ ╻ ┏━┓┏┓ ┏━┓┏━┓┏━┓╺┳╸╻┏━┓┏┓╻ |
||||
|
┃ ┃ ┃┃ ┃ ┣━┫┣┻┓┃ ┃┣┳┛┣━┫ ┃ ┃┃ ┃┃┗┫ |
||||
|
┗━╸┗━┛┗━╸┗━╸╹ ╹┗━┛┗━┛╹┗╸╹ ╹ ╹ ╹┗━┛╹ ╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
Git usage in the bigger picture. |
||||
|
|
||||
|
- Issue tracking, |
||||
|
- Pull Request handling, |
||||
|
- Assigning work, |
||||
|
- Milestones, Projects, etc. |
||||
|
|
||||
|
Example frontends: |
||||
|
- GitHub |
||||
|
- Gitlab |
||||
|
- Gitea |
||||
|
- Gogs |
||||
|
|
@ -0,0 +1,18 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
╻┏━┓┏━┓╻ ╻┏━╸ ╺┳╸┏━┓┏━┓┏━╸╻┏ ┏━╸┏━┓ |
||||
|
┃┗━┓┗━┓┃ ┃┣╸ ┃ ┣┳┛┣━┫┃ ┣┻┓┣╸ ┣┳┛ |
||||
|
╹┗━┛┗━┛┗━┛┗━╸ ╹ ╹┗╸╹ ╹┗━╸╹ ╹┗━╸╹┗╸ |
||||
|
|
||||
|
|
||||
|
|
||||
|
- Note-tacking, |
||||
|
- feature requests, |
||||
|
- track bug reports from clients. |
||||
|
|
||||
|
- Use labels to categorize |
||||
|
- bug, good-first-issue, enhancement, etc. |
||||
|
- Associate milestones and assignees |
||||
|
|
||||
|
An issue should eventually be turned into a pull request (PR). |
@ -0,0 +1,20 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━┓╻ ╻╻ ╻ ┏━┓┏━╸┏━┓╻ ╻┏━╸┏━┓╺┳╸┏━┓ |
||||
|
┣━┛┃ ┃┃ ┃ ┣┳┛┣╸ ┃┓┃┃ ┃┣╸ ┗━┓ ┃ ┗━┓ |
||||
|
╹ ┗━┛┗━╸┗━╸ ╹┗╸┗━╸┗┻┛┗━┛┗━╸┗━┛ ╹ ┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
At the heart of your team's workflow |
||||
|
|
||||
|
- Accompanies a branch |
||||
|
- Gives the team |
||||
|
- a plattform to discuss progress, |
||||
|
- the branches history and |
||||
|
- a list of all introduces changes. |
||||
|
|
||||
|
Project lead can review and ask for changes one a line-by-line basis |
||||
|
|
||||
|
Basis for Continuous Integration |
@ -0,0 +1,22 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸┏━┓┏┓╻╻ ╻┏━╸┏┓╻╺┳╸╻┏━┓┏┓╻┏━┓╻ ┏━╸┏━┓┏┳┓┏┳┓╻╺┳╸┏━┓ |
||||
|
┃ ┃ ┃┃┗┫┃┏┛┣╸ ┃┗┫ ┃ ┃┃ ┃┃┗┫┣━┫┃ ┃ ┃ ┃┃┃┃┃┃┃┃ ┃ ┗━┓ |
||||
|
┗━╸┗━┛╹ ╹┗┛ ┗━╸╹ ╹ ╹ ╹┗━┛╹ ╹╹ ╹┗━╸ ┗━╸┗━┛╹ ╹╹ ╹╹ ╹ ┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
Syntax: |
||||
|
┌─────────────────────────────────────┐ |
||||
|
│<type>[optional scope]: <description>│ |
||||
|
│ │ |
||||
|
│[optional body] │ |
||||
|
│ │ |
||||
|
│[optional footer(s)] │ |
||||
|
└─────────────────────────────────────┘ |
||||
|
|
||||
|
- They enable |
||||
|
- automated CHANGELOGs and, |
||||
|
- automated semantic version bump and |
||||
|
- greatly help with readability. |
@ -0,0 +1,15 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸┏━┓┏┓╻╻ ╻┏━╸┏┓╻╺┳╸╻┏━┓┏┓╻┏━┓╻ ┏━╸┏━┓┏┳┓┏┳┓╻╺┳╸┏━┓ |
||||
|
┃ ┃ ┃┃┗┫┃┏┛┣╸ ┃┗┫ ┃ ┃┃ ┃┃┗┫┣━┫┃ ┃ ┃ ┃┃┃┃┃┃┃┃ ┃ ┗━┓ |
||||
|
┗━╸┗━┛╹ ╹┗┛ ┗━╸╹ ╹ ╹ ╹┗━┛╹ ╹╹ ╹┗━╸ ┗━╸┗━┛╹ ╹╹ ╹╹ ╹ ┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
┌──────────────────────────────────────────────────────────┐ |
||||
|
│feat: allow provided config object to extend other configs│ |
||||
|
│ │ |
||||
|
│BREAKING CHANGE: `extends` key in config file is now │ |
||||
|
│used for extending other config files │ |
||||
|
└──────────────────────────────────────────────────────────┘ |
@ -0,0 +1,12 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏┳┓╻┏━┓┏━╸┏━╸╻ ╻ ┏━┓┏┓╻┏━╸┏━┓╻ ╻┏━┓ |
||||
|
┃┃┃┃┗━┓┃ ┣╸ ┃ ┃ ┣━┫┃┗┫┣╸ ┃ ┃┃ ┃┗━┓ |
||||
|
╹ ╹╹┗━┛┗━╸┗━╸┗━╸┗━╸╹ ╹╹ ╹┗━╸┗━┛┗━┛┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
- Protect master branch |
||||
|
- Repository setting for PRs help with team workflow |
||||
|
- e.g. can be set to create merge commits. |
@ -0,0 +1,17 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━┓┏┓╻┏━┓╻ ╻ ╻┏━┓╻┏━┓ ╻┏┓╻┏━┓┏━┓┏━╸┏━╸╺┳╸╻┏━┓┏┓╻ |
||||
|
┣━┫┃┗┫┣━┫┃ ┗┳┛┗━┓┃┗━┓ ╺━╸ ┃┃┗┫┗━┓┣━┛┣╸ ┃ ┃ ┃┃ ┃┃┗┫ |
||||
|
╹ ╹╹ ╹╹ ╹┗━╸ ╹ ┗━┛╹┗━┛ ╹╹ ╹┗━┛╹ ┗━╸┗━╸ ╹ ╹┗━┛╹ ╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
- Search through: code, modifications, commits or commit messages. |
||||
|
- Look at history of lines of code |
||||
|
- Binary search for bugs |
||||
|
- List of most recent changes |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,19 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸╻╺┳╸ ╻ ┏━┓┏━╸ |
||||
|
┃╺┓┃ ┃ ┃ ┃ ┃┃╺┓ |
||||
|
┗━┛╹ ╹ ┗━╸┗━┛┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
- $ git log |
||||
|
- --patch, --after, --since, --before, --committer |
||||
|
- -S"<search-pattern>" // code |
||||
|
- -L <start>,<end>:<filename> // history of lines of code |
||||
|
- -L :<function-name>:<filename> // history of a function |
||||
|
- --grep "<search-pattern>" // commit messages |
||||
|
|
||||
|
- $ git log --oneline |
||||
|
- $ git log --graph |
||||
|
|
@ -0,0 +1,30 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸╻╺┳╸ ┏┓ ╻ ┏━┓┏┳┓┏━╸ |
||||
|
┃╺┓┃ ┃ ┣┻┓┃ ┣━┫┃┃┃┣╸ |
||||
|
┗━┛╹ ╹ ┗━┛┗━╸╹ ╹╹ ╹┗━╸ |
||||
|
|
||||
|
|
||||
|
|
||||
|
- $ git blame <filename> |
||||
|
┌────────────────────────────────────────────────────────────────┐ |
||||
|
│[spranger@gitWorkshop/stagingArea] git blame testfile1 │ |
||||
|
│2 days ago Stefan ^3b4a655│ 1 │ #include <stdio.h> │ |
||||
|
│ │ 2 │ #include <algorithms> │ |
||||
|
│a day ago Stefan 08b88afb│ 3 │ #include <sstream> │ |
||||
|
│2 days ago Stefan ^3b4a655│ 4 │ │ |
||||
|
│ │ 5 │ int main() { │ |
||||
|
│3 hours ago Stefan a2c365ad│ 6 │ int a = 1; │ |
||||
|
│ │ 7 │ int b = 2; │ |
||||
|
│2 days ago Stefan ^3b4a655│ 8 │ │ |
||||
|
│2 days ago Stefan a0bd6d8c│ 9 │ │ |
||||
|
│ │ 10 │ return a+b; │ |
||||
|
│2 days ago Stefan ^3b4a655│ 11 │ } │ |
||||
|
└────────────────────────────────────────────────────────────────┘ |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,15 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸╻╺┳╸ ┏━╸┏━┓┏━╸┏━┓ |
||||
|
┃╺┓┃ ┃ ┃╺┓┣┳┛┣╸ ┣━┛ |
||||
|
┗━┛╹ ╹ ┗━┛╹┗╸┗━╸╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
Powerful tool to search for code snippets |
||||
|
|
||||
|
- $ git grep "<search-pattern>" |
||||
|
- -A <n>, -B <n>, -C <n> |
||||
|
- --show-function/-p |
||||
|
- --function-context/-W |
@ -0,0 +1,22 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸╻╺┳╸ ┏┓ ╻┏━┓┏━╸┏━╸╺┳╸ |
||||
|
┃╺┓┃ ┃ ┣┻┓┃┗━┓┣╸ ┃ ┃ |
||||
|
┗━┛╹ ╹ ┗━┛╹┗━┛┗━╸┗━╸ ╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
Binary search to find commit that introduced a bug. |
||||
|
|
||||
|
┌──────────────────────────────────────────┐ |
||||
|
│$ git bisect start │ |
||||
|
│$ git bisect bad <commit-ish> │ |
||||
|
│$ git bisect good <commit-ish> │ |
||||
|
└──────────────────────────────────────────┘ |
||||
|
|
||||
|
┌──────────────────────────────────────────┐ |
||||
|
│$ git bisect start HEAD HEAD~10 -- │ |
||||
|
│$ git bisect run make test │ |
||||
|
│$ git bisect reset │ |
||||
|
└──────────────────────────────────────────┘ |
@ -0,0 +1,12 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━┓┏━┓╺┳╸┏━╸╻ ╻╻┏┓╻┏━╸ |
||||
|
┣━┛┣━┫ ┃ ┃ ┣━┫┃┃┗┫┃╺┓ |
||||
|
╹ ╹ ╹ ╹ ┗━╸╹ ╹╹╹ ╹┗━┛ |
||||
|
|
||||
|
|
||||
|
|
||||
|
- Revert already commited changes |
||||
|
- Pick a range of commits from different branches |
||||
|
- Turn a commit into a git-readable file |
@ -0,0 +1,14 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸╻╺┳╸ ┏━┓┏━╸╻ ╻┏━╸┏━┓╺┳╸ |
||||
|
┃╺┓┃ ┃ ┣┳┛┣╸ ┃┏┛┣╸ ┣┳┛ ┃ |
||||
|
┗━┛╹ ╹ ╹┗╸┗━╸┗┛ ┗━╸╹┗╸ ╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
Revert commits via new commits |
||||
|
|
||||
|
- Should be used when the commits are already public |
||||
|
|
||||
|
- $ git revert <commit-ish>.. |
@ -0,0 +1,20 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸╻╺┳╸ ┏━╸╻ ╻┏━╸┏━┓┏━┓╻ ╻ ┏━┓╻┏━╸╻┏ |
||||
|
┃╺┓┃ ┃ ┃ ┣━┫┣╸ ┣┳┛┣┳┛┗┳┛╺━╸┣━┛┃┃ ┣┻┓ |
||||
|
┗━┛╹ ╹ ┗━╸╹ ╹┗━╸╹┗╸╹┗╸ ╹ ╹ ╹┗━╸╹ ╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
Specify commits and apply them onto your HEAD |
||||
|
|
||||
|
- $ git cherry-pick <commit-ish>.. |
||||
|
|
||||
|
- $ git cherry-pick ..master |
||||
|
- essentially the same as $ git rebase master |
||||
|
|
||||
|
- Useful if e.g. a hotfix has been pushed to a stable branch |
||||
|
- Might need to clean such commits before merging |
||||
|
|
||||
|
|
@ -0,0 +1,15 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏━╸┏━┓┏━┓┏┳┓┏━┓╺┳╸ ┏━┓┏━┓╺┳╸┏━╸╻ ╻ ┏┓ ┏━┓┏━┓┏━┓╻ ╻ ╻ |
||||
|
┣╸ ┃ ┃┣┳┛┃┃┃┣━┫ ┃ ╺━╸┣━┛┣━┫ ┃ ┃ ┣━┫ ┃╺╋╸ ┣━┫┣━┛┣━┛┃ ┗┳┛ |
||||
|
╹ ┗━┛╹┗╸╹ ╹╹ ╹ ╹ ╹ ╹ ╹ ╹ ┗━╸╹ ╹ ┗━┛ ╹ ╹╹ ╹ ┗━╸ ╹ |
||||
|
|
||||
|
|
||||
|
|
||||
|
In certain situations it might be sensible to send commits per mail |
||||
|
|
||||
|
- $ git format-patch -1 <commit-ish> |
||||
|
- colleague does not need to checkout your branch |
||||
|
|
||||
|
- $ git apply <filename> |
@ -0,0 +1,22 @@ |
|||||
|
|
||||
|
|
||||
|
|
||||
|
┏┳┓┏━┓┏━┓┏━╸ ┏━┓┏┓╻╺┳┓ ┏┳┓┏━┓┏━┓┏━╸ |
||||
|
┃┃┃┃ ┃┣┳┛┣╸ ┣━┫┃┗┫ ┃┃ ┃┃┃┃ ┃┣┳┛┣╸ |
||||
|
╹ ╹┗━┛╹┗╸┗━╸ ╹ ╹╹ ╹╺┻┛ ╹ ╹┗━┛╹┗╸┗━╸ |
||||
|
|
||||
|
|
||||
|
|
||||
|
- git notes, |
||||
|
- commit signing, |
||||
|
- merge strategies, |
||||
|
- git worktree, |
||||
|
- refs, |
||||
|
- git reflog, |
||||
|
- porcelain commands and scripting, |
||||
|
- the power of .gitconfig, |
||||
|
- hooks on the server, |
||||
|
- multiple remotes, |
||||
|
- etc. |
||||
|
|
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue