Git Cheat Sheet¶
Configure Tooling¶
Setting a name to be recorded in created commits
$ git config user.name "[your full name]"
Setting an email address to be recorded in commits.
$ git config user.email "[email address]"
Make Changes¶
Showing differences between staged and the last file version
$ git diff --staged
Unstaging a file while keeping it in the working tree
$ git reset [file]
Canceling the previous commit while keeping the working tree
$ git reset --soft HEAD^
Discarding a change to a file
$ git checkout -- [file]
Manage Branches¶
Creating a new branch and checking it out
$ git checkout -b [branch-name]
or
$ git branch [branch-name]
$ git checkout [branch-name]
Misc¶
Showing the commit ID of HEAD
$ git rev-parse HEAD
Retrieving files from a repository without cloaning it
$ git archive --format tar --remote [path] HEAD | tar xvf -