Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Git

Git is the most important free and open source distributed version control system today. Some software can help visualize the git commands, but if you don’t know what tools are available, you won’t be able to use them.

Important

These commands are the bread and butter of Git. You should be able to use them with ease. Practice them at https://coddy.tech/playground/git

Use caseGit Documentation
Create new or clone an existing repository / clonegit init / git clone
Switch branches or restore working tree filesgit checkout
Fetch from and integrate with another repository or a local branchgit pull
Reapply commits on top of another base tipgit rebase
Put your changes away for a bitgit stash
Remove untracked filesgit clean
Record changes to the repositorygit commit
Update remotegit push
Show commit logsgit log
Undo various Git operations, e.g. commitgit reset
Download updates from remotegit fetch

Tip

These commands are more advanced. The more you know, the better!

Use caseGit Documentation
Apply an existing commitgit cherry-pick
Use binary search to find the commit that introduced a buggit bisect
Show changes between commitsgit diff
Review PR without messing up your current workgit worktree
Who let the dogs out?git blame
Switch branchesgit switch
Restore filesgit restore

Home assignment: What are these lines doing? Explain in plain english:

git add LoginViewModel.kt
git commit --amend --no-edit
git bisect start
git bisect bad
git bisect good
git bisect good
git bisect bad
git blame -L 40,80 LoginViewModel.kt
git switch release/1.2.3
git cherry-pick 4d5c6a7
# you have a conflict in LoginViewModel,kt, which you resolve manually
git add LoginViewModel.kt
git cherry-pick --continue
git diff HEAD~3 --name-only