Create a gist now

Instantly share code, notes, and snippets.

Git Beginners Cheatsheet
#
# 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>
# 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)
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment