Cheatography
https://cheatography.com
Github - Codeschool Git Real
PANIC Commandsgit reset --soft HEAD^ | Undo last commit, put changes into staging | git commit --amend -m "New Message" | Change the last commit | git reset --hard HEAD^ | Undo last commit and all changes | git reset --hard HEAD^^ | Undo last 2 commits and all changes |
Deleting and untracking filesDelete from file system and git | git rm FILE.txt | Delete from git ONLY | git rm --cached FILE.txt |
After that, you may commit to save the delete change.
| | Better ways to show git logColorizing Log | git config --global color.ui true | One commit per line | git log --pretty=oneline | Output log the way you want | git log --pretty=format:"%h %ad- [%an] %s" | Show log and modified lines | git log --oneline -p | Show log and insertions and deletes | git log --oneline --stat | Show log with a tree visual representation | git log --oneline --graph | Limit git log until some date | git log --until=1.minute.ago | Limit git log since some date | git log --since=1.day.ago | Range git log | git log --since=1.month.ago --until=2.weeks.ago | Range git log with specifc date | git log --since=2000-01-01 --until=2012-12-21 |
Custom git log output%ad | author date | %an | author name | %h | SHA hash | %s | subject | %d | ref names |
Ex: git log --pretty=format:"%h %ad- [%an] %s"
| | Pushing FasterFirst time | git push -u origin master | Then | git push |
Git will memorize the location you want to push by first using the command -u
Git AliasesGit lol (log with some colors and visual tree) | git config --global alias.lol "log --pretty=oneline --abbrev-commit --graph --decorate" | Custom git output | git config --global alias.mylog "log --pretty=format:'%h [%an] %s' --graph" | Git status via git st | git config --global alias.st status | Git checkout via git co | git config --global alias.co checkout | Git branch via git br | git config --global alias.br branch | Git commit via git ci | git config --global alias.ci commit |
Create your own alias using the format:
git config --global alias.youralias "your command, ommiting 'git'
|
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