We have a development branch which is our master and a separate maintenance branch. I frequently have to cherry-pick commits from the master to the maintenance or vice-versa when I fix bugs. Normally I accomplish this by performing the following procedure...
The problem that I have is because the branches have become significantly divergent I have to rebuild the entire project each time I switch which takes up to 10 minutes. This is expected, but I'd like to not have to do this since I'm frequently switching between branches. So to avoid this I created a second working directory so that I have a directory for each branch. The problem with this is that I can't cherry-pick the original master commit into the maintenance directory until I've pulled that commit into the master branch of the maintenance directory from the remote. When I do this of course, I have to completely rebuild.
Is there a way to pull the commits into the master branch of my maintenance directory without switching? Or, is there a better way of doing this entirely? We recently switched to Git from CVS, so I'm not that familiar with it.
You can download the new commits into the other repository simply by running fetch
(in the other repository):
git fetch origin
However, fetch
will only update the remote tracking branches, not the local branches, so master
will not move, but origin/master
will. So you can cherry-pick the newest commit with:
git cherry-pick origin/master
(To my knowledge, there is no elegant way to create a new commit atop another branch than the one that is currently checked out, so I think you need to stick to the two repositories if you don't want to switch branches. Sounds like you'll need that anyway in order to test the changes you make on the other branch?)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With