This is a draft cheat sheet. It is a work in progress and is not finished yet.
CONFIGURE TOOLING
git config --global user.name "[name]"
|
Set the name you want attached to your commit transactions |
git config --global user.email "[email address]"
|
Set the email you want attached to your commit transactions |
CREATE REPOSITORIES
|
Creates a new local repository with the specified name |
|
Downloads a project and its entire version history |
MAKE CHANGES
|
List changed files in your working directory |
|
List changes to tracked files |
|
List file differences between staging and the last file version |
|
Add all current changes to the next commit |
|
Add some changes in [file-name] to the next commit |
git commit -m " [commit msg] "
|
Commit local changes and add msg |
|
Commit all local changes in tracked files |
|
Change the last commit* |
|
Unstage the file, but preserve its contents |
* Don‘t amend published commits!
GROUP CHANGES
|
List all local branches in the current repository |
git branch [branch-name]
|
Create new [branch] based on your current HEAD |
git branch -d [branch-name]
|
Delete specified branch |
git checkout [branch-name]
|
Switch HEAD branch |
|
Merge [branch-name] into your current HEAD |
|
Mark the current commit with a tag |
|
See what HEAD points too |
You can think of the HEAD as the "current branch". When you switch branches with git checkout
, the HEAD revision changes to point to the tip of the new branch.
SYNCHRONIZE
git remote show [remote-name]
|
Show information about a remote |
|
List all currently configured remotes |
git branch -dr [remote]/[branch]
|
Delete a branch on the remote |
|
Download all changes from [remote] but do'nt integrate into HEAD |
git pull [remote] [branch]
|
Download changes and directly merge/integrates into HEAD |
git push [remote] [branch]
|
Publish local changes on a remote |
|
Publish your tags |
git merge [remote]/[branch]
|
Combine the remote [branch] into your current HEAD |
|
Download bookmark history and incorporates changes |
git add <resolved-file>
|
Use your editor to manually solve conflicts and (after resolving) mark file as resolved |
git rm <resolved-file>
|
Use your editor to manually solve conflicts and (after resolving) mark file as resolved |
COMMIT HISTORY
|
Show all commits, starting with newest |
|
Show changes over time for a specific file |
|
Who changed what and when in [file-name] |
|
Output metadata and content changes a specific commit |
UNDO
|
Discard all local changes in your working directory |
|
Discard local changes in a specific file |
|
Revert a commit (by producing a new commit with contrary changes) |
git reset --hard [commit]
|
Discard all history and changes back to the specified commit |
|
Revert a commit (by producing a new commit with contrary changes) and preserve all changes as unstaged changes |
git reset --keep [commit]
|
Revert a commit (by producing a new commit with contrary changes) and preserve uncommitted local changes |
WORKFLOW
workspace working directory
index staging area
local repository HEAD
|