This is a draft cheat sheet. It is a work in progress and is not finished yet.
Initialising a repository
Initialising a fresh repository
|
Clone an existing repository
|
Clone an existing repository into a custom directory git clone <url> <directory>
|
Clone an existing repository into current directory
|
Managing branches
Get help
|
List local branches
|
List remote branches
|
List local and remote branches
|
Delete a local branch
|
Rename current branch git branch -M <new-name>
|
Track a different remote branch git branch -u <remote-branch>
|
Find local branches that have been merged into a branch git branch --merged <branch>
|
Find remote branches that have been merged into a branch git branch -r --merged <branch>
|
Find all branches that have been merged into a branch git branch -a --merged <branch>
|
|
|
Managing Remotes
List remotes
|
Add new remote git remote add <name> <url>
|
Change remote url git remote set-url <name> <url>
|
Change remote push url git remote set-url --push <name> <url>
|
Change remote pull url git remote set-url --pull <name> <url>
|
Push Changes
Push local changes
|
Force push local changes
|
Push to a different remote branch git push <remote-branch>
|
Push to a different remote branch and start tracking it git push -u <remote-branch>
|
Push to a remote branch that has a different name git push <remote-branch> <local-branch>
|
|