0% found this document useful (0 votes)
206 views3 pages

Git Cheat Sheet: Getting Started

The document is a Git cheat sheet that provides concise summaries of common Git commands for getting started with Git, working with local and remote repositories, branches and tags, merging, rebasing, stashing changes, and resetting or reverting commits. It lists the basic syntax for over 30 different Git commands.

Uploaded by

kirun15
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
206 views3 pages

Git Cheat Sheet: Getting Started

The document is a Git cheat sheet that provides concise summaries of common Git commands for getting started with Git, working with local and remote repositories, branches and tags, merging, rebasing, stashing changes, and resetting or reverting commits. It lists the basic syntax for over 30 different Git commands.

Uploaded by

kirun15
Copyright
© © All Rights Reserved
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/ 3

Cheetyr – Git Cheat Sheet 01/06/1938 Saka, 12:10

Git Cheat Sheet


Getting Started
$ git clone [repository] Clone an existing repository

$ git init Create a new local respository

Local
$ git status Show changed 5les in your working directory

$ git diff Show changes to tracked 5les

$ git add -A Stage all changes

$ git add -u Stage modi5ed and deleted 5les, but not untracked 5les

$ git add . Stage new and modi5ed 5les, but not deleted 5les

$ git add [file] Stage ["le]

$ git commit Commit previously staged changes

$ git commit -m "[message]" Commit previously staged changes with a message

$ git commit -a Commit all local changes in tracked 5les

$ git commit --amend Change the last commit

$ git log Show all commits, starting with most recent

$ git log -p [file] Show changes over time to ["le]

$ git blame [file] Show changes for ["le] with time and author

Branches & Tags


$ git branch List local branches

$ git branch -a List both local and remote branches

$ git branch -r List remote branches

$ git checkout [branch] Switch HEAD branch

http://www.cheetyr.com/git Page 1 of 3
Cheetyr – Git Cheat Sheet 01/06/1938 Saka, 12:10

$ git branch [new branch] Create new branch based on current HEAD

$ git branch --track [new Create new tracking branch based on a remote branch
branch] [remote branch]

$ git branch -d [branch] Delete local branch

$ git tag [tag name] Mark the current commit with a tag

Remote
$ git remote update Refresh list of remotes

$ git remote -v List all currently con5gured remotes

$ git remote show [remote] Display information about [remote]

$ git remote add [remote] Add a new remote, named [remote]


[url]

$ git fetch [remote] Download all changes from [remote], don't integrate into
HEAD

$ git pull [remote] Download changes and merge to HEAD


[branch]

$ git push [remote] Publish local changes


[branch]

$ git push [remote] : Delete a branch on the remote


[branch]

$ git push --tags Publish tags

Merge & Rebase


$ git merge [branch] Merge [branch] into your current HEAD

$ git rebase [branch] Rebase your HEAD onto [branch]

$ git rebase --abort Abort a rebase

$ git rebase --continue Continue a rebase after resolving conFicts

$ git mergetool Use con5gured merge tool to resolve conFicts

http://www.cheetyr.com/git Page 2 of 3
Cheetyr – Git Cheat Sheet 01/06/1938 Saka, 12:10

Stash
$ git stash Temporarily store all modi5ed tracked 5les

$ git stash pop Restore most recently stashed 5les

$ git stash list List all stashed changes

$ git stash drop Discard most recently stashed changeset

Reset & Revert


$ git reset --hard HEAD Discard all local changes in your working directory

$ git checkout HEAD [file] Discard local changes in ["le]

$ git revert [commit] Revert a commit

$ git reset --hard [commit] Reset HEAD to a previous commit and discard all changes
since

$ git reset [commit] Reset HEAD to a previous commit and preserve all changes
as unstaged changes

$ git reset --keep [commit] Reset HEAD to a previous commit and preserve
uncommitted local changes

http://www.cheetyr.com/git Page 3 of 3

You might also like