Cheatography
https://cheatography.com
Git Cheat sheet from GitHub
Setup
Set a user name |
git config --global user.name "[firstname last name]" |
Set an email |
git config --global user.email "[valid email]" |
Set automatic command line coloring |
git config --global color.ui auto |
Setup and INIT
Initialize a directory |
git init |
Clone an entire repository via URL |
git clone [url] |
Inspect and compare
Show the commits in B but no in A |
git log branchB..branchA |
Show the commits that changed file |
git log --follow[file] |
Show the diff of in A but no in B |
git diff branchB...branchA |
Show any object in git |
git show [SHA] |
Tracking Path changes
Delete the path from project and stage the removal for commit |
git rm [file] |
Change an existing file path and stage the move |
git mv [existing-path] [new-path] |
Show all commits logs with movements in path |
git log --stat -M |
Ignoring patterns
Save a file with desired patterns as .gitignore |
*.notes/ |
Configure the file |
git config --global core.excludesfile [file] |
|
|
Stage and Snapshot
Show modified files in working directory |
git status |
Add a file to stage |
git add [file] |
Unstage a file |
git reset [file] |
Diff of what is changed but not staged |
git diff |
Diff of what is staged but not committed |
git diff --staged |
Commit your staged content |
git commit -m "[descriptive message]" |
Branch and Merge
List your branches |
git branch |
Create a new branch |
git branch [branch-name] |
Switch to another branch |
git checkout |
Merge the branch into the current |
git merge [branch] |
Show all the commits |
git log |
Share and Update
Add a git URL as an alias |
git remote add [alias] [url] |
Fetch down all the branches from git remote |
git fetch [alias] |
Merge remote branch into your current branch |
git merge [alias]/[branch] |
Transmit local branch commits to remote |
git push [alias][branch] |
Fetch and merge all commits |
git pull |
Rewrite History
Apply any commits of current branch ahead of specified one |
git rebase [branch] |
Clear staging area and rewrite working tree fro specified commit |
git reset --hard [commit] |
Temporary commits
Save modified and staged changes |
git stash |
List stack-order of stashed file changes |
git stash list |
Write working from top of stash stack |
git stash pop |
Discard the changes from top of the stack |
git stash drop |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by Monz gomz