Cheatography
https://cheatography.com
git commands reference sheet
Initializegit init | Initialize repository | git remote add <origin/alternate name> <repo url> | Link local repo with <repo URL> | git push -u origin master | Push committed changes (-u and track branch with remote) |
Commitgit add . | Adds all modified and new (untracked) files in the current directory and all subdirectories to the staging area | git commit -m <commit message> | Locally commit | git checkout . | Revert changes to local copy | git reset | Revert changes made to the index (i.e., that you have added). Warning this will reset all of your unpushed commits to master! | git revert <commit 1> <commit 2> | Revert a change that you have committed | git clean -f | Remove untracked files (e.g., new files, generated files) | git clean -fd | Remove untracked directories | git-stash | Stash the changes away in a working directory | git diff <branch 1> <branch 2> | Compare two branches | git diff <branch 1> <branch 2> --name-only | Compare two branches, file names only | git diff <branch> | Compare <branch> with current branch | git rm <file> --cached | Remove file from remote, while retaining local copy |
| | Branching, Merginggit checkout -b <branch> master | Create <branch> from master | git push -u origin <branch> | Push <branch> | git merge <branch> | Merge <branch> into current branch | git branch -d <branch> | Delete local branch if it is merged, if not -D to force delete | git push <remote_name> --delete <branch> | Delete remote branch | git branch <branch> | Create branch <branch> | git branch [-a] | List branches, -a including remote, * indicates current branch | git rebase <branch> | Rebase from <branch> into current branch, i.e. take <branch> and then apply current branch's commits onto it to create linear history | git branch -m <old> <new> git push origin :<old> <new> git push origin -u <new> | 1. Rename your local branch 2. Delete the <old> remote branch and push the <new> local branch 3. Reset the upstream branch for the <new> local branch | git diff --name-status <b1>..<b2> | Show diffs (filenames only) between two branches | git diff --name-status master | Show diffs (filenames only) between master and current branch |
Admin, Trouble-shootinggit log [-p] [-n] | Shows commit history, last n, -p differences | git remote set-url origin <new url> | Change remote url | git remote -v | List remote information | git config --global credential.helper cache git config --global credential.helper 'cache --timeout=3600' | Set git to use the credential memory cache set the cache to timeout after 1 hour (setting is in seconds) | git config [--global] user.name "FIRST_NAME LAST_NAME" | Set (global/repo) username for commits | git config [--global] user.email "MY_NAME@example.com" | Set (global/repo) email for commits |
|
Help Us Go Positive!
We offset our carbon usage with Ecologi. Click the link below to help us!
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by shribee