public
Last active

Git Beginners Cheatsheet

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8
#
# Git Tag
#
 
Lightweight: git tag <name> <commit-id>
Annotated: git tag -a <name> <commit-id>
Show tag: git show <name>
Check Annotated: git tag -v <name>
git_beginners_cheatsheet
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
# remove file from index but do not delete it.
$ git rm --cached file
 
# diff staging area with index
$ git diff --staged
 
# amend a commit
$ git commit --amend
# e. g. add a file
$ git commit -m "first commit with forgotten file"
$ git add forgotten_file
$ git commit --amend # edit commit message on base current stage
 
#
# Remotes
#
 
# Tell me something about my known remotes
git remote
 
# Tell me something about [remote-name]
git remote show [remote-name]
 
# add remote
git remote add [remote-name] [remote]
 
# rename [remote-name]
git remote rename [remote-name] [new-remote-name]
 
# get remote
git fetch [remote-name]
 
#
# Pull (=fetch + merge)
#

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.