馃尶
Git: Everyday Commands
20 cards@learner82946550
The Git commands you use every day and what they do.
Deck code
jdb3hh569d
Cards
5 of 2020 of 20
git status
Show changed, staged and untracked files.
git add <file>
Stage a file for the next commit. git add . stages everything.
git commit -m "msg"
Create a commit from staged changes with a message.
git commit --amend
Change the last commit (message or content).
git push
Send local commits to the remote branch.
Show 15 more cards
Or learn them all in the app
git pull
Fetch remote changes and merge them into the current branch.
git fetch
Download remote changes without merging them.
git switch -c <branch>
Create a new branch and switch to it.
Old way: git checkout -b <branch>
git branch
List local branches. -d <name> deletes a branch.
git merge <branch>
Merge another branch into the current one.
git rebase <branch>
Replay your commits on top of another branch for a linear history.
git stash
Temporarily save uncommitted changes and clean the working tree.
git stash pop
Restore the last stashed changes and remove them from the stash.
git log --oneline
Show commit history, one line per commit.
git diff
Show unstaged changes. --staged shows staged changes.
git restore <file>
Discard local changes in a file.
git restore --staged <file>
Unstage a file (keep the changes).
git reset --soft HEAD~1
Undo the last commit but keep its changes staged.
git revert <commit>
Create a new commit that undoes another commit. Safe for shared branches.
git cherry-pick <commit>
Apply a single commit from another branch to the current one.