Cheatography
https://cheatography.com
Config
git config --global user.name "[name]" |
git config --global user.email "[email address]" |
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|--amend|-am] "texto" (Dont amend published commits) |
Tag
git tag -a 1.1 -m "Descripcion" [HASH] |
git tag -l |
git tag -d [HASH] |
git push --tags |
Log
git log --graph|--oneline |
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 "file" (undone current work of file) |
Branch
git branch "name" | git checkout -b "name" |
git branch [-av] (local and remote) |
git branch -m "old-name" "new-name" |
git checkout "HASH" (temp view of hash) |
git merge "branch2" (merge current-branch with branch2) |
git branch -d |
Stash
git stash |
git stash list |
git stash apply |
git stash drop |
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-sensitive) |
|
|
Remove wrong files commited before gitignore
git rm -r --cached . |
git add . |
git commit -m "Remover archivos accidentalmente agregados al commit antes de ser añadidos al .gitignore" |
Keep folders
touch .gitkeep |
folder_with_tmp_files/* |
!folder_with_tmp_files/.gitkeep |
git-flow
[apt|brew] install git-flow |
git flow init |
Feature
git flow feature |
start |
[feature-name] |
|
finish |
[feature-name] |
|
publish |
[feature-name] (send to remote) |
|
track |
[feature-name] (get remote feature) |
Release
git flow release |
start |
[release-name] [optional base hash in dev] |
|
publish |
[release-name] |
|
track |
[release-name] |
|
finish |
[release-name] |
Hotfix
git flow hotfix |
start |
[hotfix-name] [optional base hash in dev] |
|
finish |
[hotfix-name] |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets