This Git cheatsheet provides essential commands for managing commits, changes, and branches. It includes instructions for adding, reverting, and stashing changes, as well as tagging commits and synchronizing with remote repositories. The document serves as a quick reference for common Git operations to streamline version control tasks.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
16 views2 pages
Cheatsheet
This Git cheatsheet provides essential commands for managing commits, changes, and branches. It includes instructions for adding, reverting, and stashing changes, as well as tagging commits and synchronizing with remote repositories. The document serves as a quick reference for common Git operations to streamline version control tasks.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
Git Cheatsheet Create a new commit, reverting changes from
git revert [commit sha] the specified commit. It generates an inversion
of changes. Adding changes without much effort git checkout <path> discard changes in the working tree git add -u <path> add all tracked files to the staging area git restore [-W/-- git add -p <path> interactively pick which files to stage discard changes in the working tree worktree] <path> git add -p <path> interactively pick which files to stage git restore -S/--staged git add -p <path> interactively pick which files to stage remove a file from a staging area <path> git add -p <path> interactively pick which files to stage discard changes in the working tree and to the git restore -SW <path> git add -p <path> interactively pick which files to stage staged files git add -p <path> interactively pick which files to stage git reset <path> remove a file from the staging area git add -p <path> interactively pick which files to stage remove the latest commit from the current branch and: Storing changes • --soft - keep file changes in the working tree and stage them; put current changes in the working tree into git reset [mode] HEAD^ git stash [push] [path] • --mixed - keep file changes; stash for later use • --keep - reset only files which are different apply stored stash content into working tree, between current HEAD and the last commit git stash pop and clear stash • --hard - do not keep file changes delete a specific stash from all the previous git stash drop stashes Tagging commits git tag list all tags Inspecting diffs git tag <name> [commit create a tag reference named name for the show changes between working tree and sha] current or specific commit git diff [path] staging area git tag -a <name> -m git diff --cached/--staged show any changes between the staging area create an annotated tag with the given message <message> [path] and the repository git tag -d <name> delete the tag with the given name git diff > file.patch generate a patch file for current changes Synchronizing repositories Reverting changes fetch changes from the remote, but not update git fetch [remote] rebase the current branch on top of another tracking branches git rebase specified branch delete remote refs that were removed from the git fetch --prune [remote] git rebase -i [commit sha] start an interactive rebase remote repository fetch changes from the remote and merge git pull [remote] current branch with its upstream git pull -r/--rebase fetch changes from the remote and rebase [remote] current branch on top of the upstream git push -u [remote] push local branch to a remote repository and [branch] set its copy as an upstream