0

My remote git repo has two branches 'master' (for the next release) and 'maint' (for fixing bugs in the current release). These branches are tracked locally. I am on 'master' which is up-to-date. Someone pushed changes in 'maint' to the remote which I want to merge into 'master'. The obvious way is:

git checkout maint git pull git checkout master git merge maint git push 

However, this will excessively touch my working copy, leading to long recompilation times for master. Is there a sequence of git commands which achieves the merge without checkout, i.e., without touching the local files that are unaffected by the last patches in maint I am merging in?

I tried

git merge origin/maint 

which did the job for master, but then maint is behind and the subsequent

git push 

fails, complaining about the maint -> maint part. To get maint up to date, I had to

git checkout maint git pull 

but this is precisely what I want to avoid.

0

1 Answer 1

2

Ok, according to the link provided by Rohit Jain, the solution is

git fetch origin maint:maint git merge maint git push 
Sign up to request clarification or add additional context in comments.

3 Comments

I would prefer it if you delete this answer, since it's already covered by mine in the linked question, which your question has been closed as a duplicate of. That way all of the answers are in one place. But it's up to you.
I only asked this question because my searches with the keywords contained in the question header did not turn up anything useful. I think leaving the question and answer here for others searching with similar phrases makes sense for this reason.
Actually, since your question has been marked as a duplicate, if you look at the top, it already links to a canonical question that already has answers, so if other people find your question, they already have a link to that will take them to other answers. But whatever.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.