Github Cheat Sheet
Git is a awesome SCM solution. Today GitHub is where everything happens. Pretty much everything in sense of open source is there. It`s a great model todo contribution based on the idea of Pull Requests or just PR.
However git and github could be complicated sometimes and there are situations you need do some commands get things done properly. IMHO command line tool is best them UI tools - maybe because when i start using git was not good tools around.
So today i just want to share a very simple Cheat Sheet for GitHub/Git that i use pretty much everyday - I would really love to create less branches and spent less part of my day doing this but unfortunately everybody is doing git full witch is not nice.
GitHub Cheat Sheet
Have Fun :-)
Cheers,
Diego Pacheco
However git and github could be complicated sometimes and there are situations you need do some commands get things done properly. IMHO command line tool is best them UI tools - maybe because when i start using git was not good tools around.
So today i just want to share a very simple Cheat Sheet for GitHub/Git that i use pretty much everyday - I would really love to create less branches and spent less part of my day doing this but unfortunately everybody is doing git full witch is not nice.
GitHub Cheat Sheet
git checkout -b [name_of_your_new_branch]
git push origin [name_of_your_new_branch]
git branch
git clone -b [branch_name] [remote_repo_git]
git checkout -b [name_of_your_new_branch]
git push origin [name_of_your_new_branch]
git push upstream [name_of_your_new_branch]
Delete LOCAL
git branch -d [NAME_OF_LOCAL_BRANCH]
# IF you want to FORCE to delete you can do
git branch -D [NAME_OF_LOCAL_BRANCH]
Delete REMOTE
git push origin --delete NAME_OF_REMOTE_BRNACH
git clone [GIT_URL_MASTER]
git fetch origin pull/[PULL_REQUEST_ID]/head:[GIT_BRANCHNAME]
git checkout [GIT_BRANCHNAME]
git remote -v
git remote add upstream [HTTPS_URL_GIT_MASTER]
git remote -v
git fetch upstream
git checkout master
git merge upstream/master
git checkout [BRANCH_I_WANT_SYNC]
git remote -v
git remote add upstream [HTTPS_URL_GIT_MASTER]
git remote -v
git fetch upstream
git merge upstream/master
# RESOLVE ALL CONFICTS - IF THERE ARE ANY
git commit -m "Merge Master"
git push
git fetch origin $remote-branch:$new-local-branch
git tag
git tag -a v1.4 -m "my version 1.4"
git tag
git push origin v1.4
git reset
git status
git push origin --delete $remote-branch-name
git checkout --orphan $NEWBRANCH-NAME
git rm -rf .
# Edit your files
git add .
git commit -m "my commit"
git push
git branch -a
git clone <repo_git>
git checkout tags/<tag_name> -b <branch_name>
git fetch upstream
git merge upstream/master --strategy-option theirs
git status --porcelain | awk '{if ($1=="UD") print $2}' | xargs git rm
git commit -m "Merge Master"
git push
# Backup first :-)
git reset --hard HEAD~3
git checkout -b master origin/master
Have Fun :-)
Cheers,
Diego Pacheco