简体   繁体   中英

Git Maintain two branches history and be able to git push

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? PS I don't want to loose any history on either branches

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM