Can you merge and push another branch using git?
My current process is:
git checkout dev
- make changes and commits (& push to development branch on origin occasionally)
git checkout master
git merge dev
git push origin master
git checkout dev
Would it be possible to instead merge from the development branch to master without checking out the master branch? And then would it be further possible to push the master branch without checking it out first?
eg.
- ''
- ''
- merge
dev
intomaster
wh开发者_如何学运维ile indev
branch - push
master
toorigin
while indev
branch
I am trying to eliminate the checkouts, as they are somewhat slow.
One simple solution would be to have 2 Git repos.
- One with a working directory resulting from "
git checkout master
" - One with a working directory resulting from "
git checkout dev
", clone from the first
You would replace your (slow) 'checkout' steps by "cd (right repo) ; git fetch
", before merging and pushing what you need.
I gather a fetch would be much faster than a checkout in your case.
That solution has a cost, though (and not just in disk space, which is remarkably cheap those days): it means potentially two development environment (two sets of settings for IDE editor, ...).
If you're the only one pushing to master, this workflow would get you there I think:
#while on your local dev branch:
git pull origin master #make sure there are no changes on master that aren't on your dev branch
git push origin dev:master #pushes your local dev branch to the remote master branch
This workflow will work all right if it's just you but can get pretty messy if lots of developers are working on different feature sets. Conflicts tend to abound in that scenario.
精彩评论