Show Menu
Cheatography

Git Resume Cheat Sheet by

Config

git config --global user.name "­[na­me]­"
git config --global user.email "­[email addres­s]"
git config --global color.ui auto

Init

git init [dir-name]
git clone [url]
git remote add [origin] [url]
git remove -v (list of remote)
git remote remove [origin]

Stage

git add [File|.|-A]
git status
git diff --staged
git commit [-m|--­ame­nd|-am] "­tex­to" (Dont amend published commits)

Tag

git tag -a 1.1 -m "­Des­cri­pci­on" [HASH]
git tag -l
git tag -d [HASH]
git push --tags

Log

git log --grap­h|-­-on­eline
git log -p file
git blame archivo
git reflog
 

Reset

git reset --soft [HASH] (solo commit)
git reset --mixed [HASH] (solo commit y staging)
git reset --hard [HASH] (commit, staging y worktree)
git reset --hard HEAD (undone current work)
git reset HEAD (undone git add)
git checkout HEAD "­fil­e" (undone current work of file)

Branch

git branch "­nam­e" | git checkout -b "­nam­e"
git branch [-av] (local and remote)
git branch -m "­old­-na­me" "­new­-na­me"
git checkout "­HAS­H" (temp view of hash)
git merge "­bra­nch­2" (merge curren­t-b­ranch with branch2)
git branch -d

Stash

git stash
git stash list
git stash apply
git stash drop

Cherry Pick

git cherry pick [HASH]

Fetch, pull, push

git fetch origin [branch]
git pull origin [branch]
git push -u origin branch

Search, rename

git grep "hola mundo" [v2.x]
git mv [old-name] [new-name] (move o change name case-s­ens­itive)
 

Remove wrong files commited before gitignore

git rm -r --cached .
git add .
git commit -m "­Remover archivos accide­nta­lmente agregados al commit antes de ser añadidos al .gitig­nor­e"

Keep folders

touch .gitkeep
folder­_wi­th_­tmp­_fi­les/*
!folde­r_w­ith­_tm­p_f­ile­s/.g­itkeep

git-flow

[apt|brew] install git-flow
git flow init

Feature

git flow feature
start
[featu­re-­name]
 
finish
[featu­re-­name]
 
publish
[featu­re-­name] (send to remote)
 
track
[featu­re-­name] (get remote feature)

Release

git flow release
start
[relea­se-­name] [optional base hash in dev]
 
publish
[relea­se-­name]
 
track
[relea­se-­name]
 
finish
[relea­se-­name]
git push --tags

Hotfix

git flow hotfix
start
[hotfi­x-name] [optional base hash in dev]
 
finish
[hotfi­x-name]
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Git Cheat Sheet