Show Menu
Cheatography

Github - Codeschool Git Real Cheat Sheet by

Github - Codeschool Git Real

PANIC Commands

git reset --soft HEAD^
Undo last commit, put changes into staging
git commit --amend -m "New Messag­e"
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 files

Delete 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 log

Colorizing Log
git config --global color.ui true
One commit per line
git log --pret­ty=­oneline
Output log the way you want
git log --pret­ty=­for­mat­:"%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 repres­ent­ation
git log --oneline --graph
Limit git log until some date
git log --unti­l=1.mi­nut­e.ago
Limit git log since some date
git log --sinc­e=1.da­y.ago
Range git log
git log --sinc­e=1.mo­nth.ago --unti­l=2.we­eks.ago
Range git log with specifc date
git log --sinc­e=2­000­-01-01 --unti­l=2­012­-12-21

Custom git log output

%ad
author date
%an
author name
%h
SHA hash
%s
subject
%d
ref names
Ex: git log --pret­ty=­for­mat­:"%h %ad- [%an] %s"
 

Pushing Faster

First 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 Aliases

Git lol (log with some colors and visual tree)
git config --global alias.lol "log --pret­ty=­oneline --abbr­ev-­commit --graph --deco­rat­e"
Custom git output
git config --global alias.m­ylog "log --pret­ty=­for­mat:'%h [%an] %s' --grap­h"
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'
                   
 

Comments

Thank you, great know how

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Git Cheat Sheet
          Git Flow Cheat Sheet
          Git Cheat Sheet by SamCollett [RUS] WIP Cheat Sheet