0

I have two branches that look like this

o--o--A--B-C--D env1 (master), cherry-picking from env2
       \
        X--C--D env2 

Only different between these two branches is environment settings. I want to maintain these two branches because it's quite easy for me to just git checkout to switch between environments.

Now the problem is, git push allows env2, but rejects env1(master). So how do other people get latest commits(mostly cherry-picked from env2) from env1? P.S. I don't want to loose any history on either branches

Xuphey
  • 50
  • 5

1 Answers1

0

If git push is rejecting your commit, there's a good reason! Read the message. Chances are it's because someone else has also pushed to master since your last fetch. Pushing your state would throw away someone else's work. You need to fetch their changes, merge yours in, and then push the results.

git fetch
git checkout master
git merge origin/master
git push origin master
Peter Lundgren
  • 8,787
  • 2
  • 26
  • 21
  • but I want to maintain two separate branches, doesn't it mean that merging with other branch will make only 1 branch left? – Xuphey May 20 '13 at 13:25
  • ha, I get it now, you were right Peter. All the time I was stuck at the Non-fast-forward thing, never thought about that. It was only me using the repo, but in several terminals. – Xuphey May 20 '13 at 13:34