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 case | Git Documentation |
|---|---|
Create new or clone an existing repository / clone | git init / git clone |
Switch branches or restore working tree files | git checkout |
Fetch from and integrate with another repository or a local branch | git pull |
Reapply commits on top of another base tip | git rebase |
Put your changes away for a bit | git stash |
Remove untracked files | git clean |
Record changes to the repository | git commit |
Update remote | git push |
Show commit logs | git log |
Undo various Git operations, e.g. commit | git reset |
Download updates from remote | git fetch |
Tip
These commands are more advanced. The more you know, the better!
| Use case | Git Documentation |
|---|---|
Apply an existing commit | git cherry-pick |
Use binary search to find the commit that introduced a bug | git bisect |
Show changes between commits | git diff |
Review PR without messing up your current work | git worktree |
Who let the dogs out? | git blame |
Switch branches | git switch |
Restore files | git 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