ineedtostudy.com
Log in Sign up
← Discover

Version control

Everyday Git Commands

13 terms · by ineedtostudy · updated 4 hours ago

Sign up or log in to track what you have mastered. You can still study this set as a guest.

Terms in this set

git status
What has changed, what is staged, and which branch you are on.
git add -p
Stage changes hunk by hunk instead of whole files.
git commit --amend
Replace the previous commit. Rewrites history, so avoid it after pushing.
git log --oneline --graph
Compact history with the branch topology drawn alongside.
git diff vs git diff --staged
The first shows unstaged changes, the second what is about to be committed.
git switch -c <name>
Create a branch and move to it. The modern replacement for checkout -b.
git restore <file>
Discard uncommitted changes to a file. The modern replacement for checkout -- file.
git merge vs git rebase
Merge preserves history and adds a merge commit; rebase replays your commits on top for a linear history.
git stash
Shelve uncommitted work and restore a clean tree. Recover it with stash pop.
git cherry-pick <sha>
Apply one commit from elsewhere onto the current branch.
git reset --soft vs --hard
Soft moves the branch pointer and keeps your changes staged; hard discards them entirely.
git revert <sha>
Create a new commit that undoes an old one. Safe on shared branches, unlike reset.
git bisect
Binary search through history to find the commit that introduced a bug.