Show 45 more cards
Or learn them all in the app
git commit -m "message"
save the staged changes as a new commit
git commit --amend
replace the last commit, for example to fix its message or add a forgotten file
git log
show the commit history
git log --oneline --graph
show a compact history with a graph of branches
git diff
show changes that are not staged yet
git diff --staged
show changes staged for the next commit
git show <commit>
show a commit's message and changes
git blame <file>
show who last changed each line of a file, and in which commit
git branch
list local branches
git branch <name>
create a new branch at the current commit
git branch -d <name>
delete a branch that has been merged
git switch <branch>
switch to another branch
git switch -c <branch>
create a new branch and switch to it
git checkout <branch>
the older command for switching branches; it can also restore files
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 rebase -i HEAD~3
interactively edit, squash or reorder the last three commits
git cherry-pick <commit>
apply a single commit from another branch to the current one
git remote -v
list remote repositories and their URLs
git fetch
download new commits from the remote without changing your branches
git pull
fetch remote changes and merge or rebase them into the current branch
git push
upload local commits to the remote
git push -u origin <branch>
push a new branch and make it track the remote branch
git push --force-with-lease
force-push, but only if nobody else has pushed to the remote branch since you last fetched
git stash
set aside uncommitted changes and clean the working directory
git stash pop
reapply the last stashed changes and remove them from the stash
git restore <file>
discard unstaged changes in a file
git restore --staged <file>
unstage a file but keep its changes
git reset --soft HEAD~1
undo the last commit but keep its changes staged
git reset --hard HEAD~1
delete the last commit and all its changes; cannot be undone easily
git revert <commit>
create a new commit that undoes an earlier one; safe for shared history
git reflog
show every place HEAD has pointed to; helps recover "lost" commits
git tag v1.0
mark the current commit with a tag, usually a release version
git clean -fd
delete untracked files and folders
git bisect
binary search through history to find the commit that introduced a bug
git config --global user.name "Name"
set the name recorded in your commits
.gitignore
a file listing patterns that Git should not track
node_modules/ and *.log
HEAD
pointer to the commit you currently have checked out
origin
the default name of the remote repository you cloned from
Working directory, staging area, repository
Git's three areas: your files, the changes prepared for the next commit, and the committed history
Detached HEAD
HEAD points to a commit instead of a branch; new commits will not belong to any branch
Merge conflict
two branches changed the same lines, so Git asks you to choose the result
Fast-forward merge
the branch pointer simply moves forward because the branches have not diverged
Pull request
a request on a hosting service such as GitHub or GitLab to review and merge one branch into another
Commit hash
the unique SHA identifier of a commit