views:

25

answers:

2

My current process is:

  1. git checkout dev
  2. make changes and commits (& push to development branch on origin occasionally)
  3. git checkout master
  4. git merge dev
  5. git push origin master
  6. 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.

  1. ''
  2. ''
  3. merge dev into master while in dev branch
  4. push master to origin while in dev branch

I am trying to eliminate the checkouts, as they are somewhat slow.

+1  A: 

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, ...).

VonC
+1  A: 

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.

Bryce