-
Notifications
You must be signed in to change notification settings - Fork 0
Git Cheatsheet
David Chandek-Stark edited this page May 19, 2015
·
1 revision
git checkout -b newbranch
# to discover remote branches, if necessary
git fetch
# then checkout
git checkout -b branch origin/branch
# OR
git checkout -b branch
git branch --set-upstream branch origin/branch
git push origin branchname
# fully merged or in HEAD
git branch -d branchname
# force delete
git branch -D branchname
git push origin --delete branchname
http://stackoverflow.com/a/1895095
# reset the index to the desired tree
git reset 56e05fced
# move the branch pointer back to the previous HEAD
git reset --soft HEAD@{1}
git commit -m "Revert to 56e05fced"
# Update working copy to reflect the new commit
git reset --hard
# Ignore these
/config/*.yml
# ... but not this one
!/config/predicate_mappings.yml
git submodule init
git submodule update
# Tag version 0.2.0
git tag -a v0.2.0 -m 'DulHydra 0.2.0'
# Push tag v0.2.0 to github
git push origin v0.2.0
git fetch upstream
git merge upstream/master # merges upstream into local master branch
I want to squash last three commits on feature-branch into one commit:
git checkout develop
git pull --rebase origin
git checkout feature-branch
git rebase develop
git rebase --interactive HEAD~3
# After rebasing
get push -f origin feature-branch
See http://ndlib.github.io/practices/one-commit-per-pull-request/ for more detail.
See http://nvie.com/posts/a-successful-git-branching-model/.
Example for create hotfix version 1.2.1
Branch from master
$ git checkout master
$ git pull
$ git checkout -b hotfix-1.2.1
[Fix stuff and commit to hotfix-1.2.1]
Merge into master
$ git checkout master
$ git pull
$ git merge --no-ff hotfix-1.2.1
$ git push origin master
Tag
$ git tag -a v1.2.1 -m "DulHydra 1.2.1"
$ git push origin v1.2.1
Merge into develop
$ git checkout develop
$ git pull
$ git merge --no-ff hotfix-1.2.1
$ git push origin develop