简体   繁体   中英

error in git trying to push after a rebase

Disclaimer: I'm sort of a git and version control newb.

At work we're thinking about using git to manage our customizations to a COTS product we purchased. I'm having a little bit of a hard time figuring out the best way to approach this.

My idea was that we would have three perm branches:

  • master (the default vendor files)
  • gold (branch of master, our added stuff + customized vendor files, this is the gold source)
  • development (branch of gold, stuff being developed, duh!)

The workflow would go something like:

  • for vendor patches: branch master, update files, merge back into master, rebase gold merging our customizations back into the vendors updated files
  • for hotfixes (our code): branch gold, fix code, merge back into gold, rebase development
  • for new features (our code): branch dev, merge back in when ready, merge into gold when we are doing a release

So in my testing, I mostly like how it's working, commit history looks good, flow seems ok, but the big problem i think i have is that it requires me to force push after the rebase. for example:

git checkout development
git checkout -b feat-myfeature
*do my thing, commit changes*
git checkout development
git merge feat-myfeature
git push

git checkout gold
git merge development
git push

git checkout master
git checkout -b patch-xxxxx
*update the vendor files, do commits*
git checkout master
git merge patch-xxxxx

git checkout gold
git rebase master
*fix conflicts, adding back our customizations*
git add .
git rebase --continue
git push (error!)

At this point git tells me I have a divergent history and i either must pull and de-conflict the exact same things i just de-conflicted with the rebase or a force push works too...I think the force push is going to cause me all sorts of headaches that I'm not even aware of and the fact that a pull forces me to fix the same conflicts again makes me think i've make a mistake with my plan somewhere along the way.

Can you guys offer any suggestions to improve this flow?

edit: formatting

You cannot push once your branches have diverged. The only time you can push changes to the server is when your branch is ahead of the remote branch and a simple fast-forward merge can be performed.

To push your rebased branch you need to force push, which overwrites the remote state of the branch. This will break things badly for anybody else who is using your branch, so warn them before you do it.

git push -f

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