Nothing fancy, just my daily mostly used commands.
a. create develop branch
git branch develop
git push -u origin develop
b. create a new Feature branch
git checkout -b some-feature develop
# Optionally, push branch to origin:
git push -u origin some-feature
# make some changes...
git status
git add some-file
git commit
c. Finish a working Feature
git pull origin develop
git checkout develop
git merge --no-ff some-feature
git push origin develop
git branch -d some-feature
# If you pushed branch to origin:
git push origin --delete some-feature
d. To Relase
git checkout -b release-0.1.0 develop
# Optional: Bump version number, commit
# Prepare release, commit
e. Finish a Release
git checkout master
git merge --no-ff release-0.1.0
git push
git checkout develop
git merge --no-ff release-0.1.0
git push
git branch -d release-0.1.0
# If you pushed branch to origin:
git push origin --delete release-0.1.0
git tag -a v0.1.0 master
git push --tags
f. To make a Hotfix
git checkout -b hotfix-0.1.1 master
g. Finish a Hotfix
git checkout master
git merge --no-ff hotfix-0.1.1
git push
git checkout develop
git merge --no-ff hotfix-0.1.1
git push
git branch -d hotfix-0.1.1
git tag -a v0.1.1 master
git push --tags
# if later, a tagged version wants to be checked out.
git checkout v0.1.1
# if want to check the information in a tag
git cat-file tag <tagname>
h. Stash
git stash
git stash list
git stash apply
git stash apply stash@{2}
i. Undo a merge
git checkout the branch you were on when merging
git stash apply stash@{2}
i. Undo a merge
git checkout the branch you were on when merging
git reset --hard
j. dump current local changes
git checkout .
k. Your PM created a branch in the Remote Server, now you need to work on it. Or upon pull request, don't pull (fetch + merge) but fetch first.
git fetch origin SOF-123-new-branch:SOF-123-new-branch
l. wanna see the diff?
$ git diff tag1 tag2
or show log between them:
git checkout .
k. Your PM created a branch in the Remote Server, now you need to work on it. Or upon pull request, don't pull (fetch + merge) but fetch first.
git fetch origin SOF-123-new-branch:SOF-123-new-branch
l. wanna see the diff?
$ git diff tag1 tag2
or show log between them:
$ git log tag1..tag2
sometimes it may be convenient to see only the list of files that were changed:
sometimes it may be convenient to see only the list of files that were changed:
$ git diff tag1 tag2 --stat
and then look at the differences for some particular file:
and then look at the differences for some particular file:
$ git diff tag1 tag2 -- some/file/name
diff from a branch to a tag:
- switch to that branch (checkout)
- $ git diff tag-v1.0.0
diff from a branch to a tag:
- switch to that branch (checkout)
- $ git diff tag-v1.0.0
ref:
http://www.codeceo.com/article/how-to-use-git-flow.html !!!!!!!!!!!
https://higoge.github.io/2015/07/07/git-basic06/ !!!!!!!!!!!!!!!!!
http://nvie.com/posts/a-successful-git-branching-model/ !!!!!!!!
https://github.com/geeeeeeeeek/git-recipes/wiki !!!!
https://git-scm.com/book/zh/v2/Git-%E5%88%86%E6%94%AF-%E5%88%86%E6%94%AF%E7%9A%84%E6%96%B0%E5%BB%BA%E4%B8%8E%E5%90%88%E5%B9%B6
https://git-scm.com/book/zh/v2/Git-%E5%88%86%E6%94%AF-%E5%88%86%E6%94%AF%E5%BC%80%E5%8F%91%E5%B7%A5%E4%BD%9C%E6%B5%81
https://git-scm.com/book/zh/v2/Git-%E5%B7%A5%E5%85%B7-%E5%82%A8%E8%97%8F%E4%B8%8E%E6%B8%85%E7%90%86
https://segmentfault.com/q/1010000000140446
http://blog.csdn.net/leedaning/article/details/51304690
http://xigua366.iteye.com/blog/2400324
https://www.oschina.net/translate/git-fetch-and-merge?print
https://stackoverflow.com/questions/3211809/git-diff-between-given-two-tags
https://stackoverflow.com/questions/4185888/how-do-i-read-tagger-information-from-a-git-tag
No comments:
Post a Comment