Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keeping branches in sync with Git

With SVN, I have the following setup:

/tags/
/trunk/
/branches/
/branches/my_feature
/branches/my_other_feature

I want to keep all the branches in sync with mainline trunk, so I periodically run an svn merge for the branch for trunk.

However, I also want to keep all the branches in sync with one another, so as to avoid conflicts, as any given branch's lifetime can be a couple of months or more. If I have a dozen branches, I would have a nasty mesh with SVN, and it would be impractical.

My question is, would using Git instead of SVN help with keeping branches in sync with one another and trunk?

like image 220
Chad Johnson Avatar asked Oct 26 '25 06:10

Chad Johnson


2 Answers

It would help you keep both branches in sync with trunk by doing a rebase.

While using the branch my_feature, execute:

git rebase master

And that will bring your changes in the master (trunk) branch to my_feature.

About keeping my_feature and my_other_feature in sync, its the same principle if one is a descendant of the other. If my_feature is not a descendant of my_other_feature or viceversa, I don't know the answer.

like image 126
eblacklight Avatar answered Oct 27 '25 20:10

eblacklight


Yes, for the most part. All three of the modern DVCSes (Git, Mercurial, and Bazaar) can tell when you last merged and won't try to remerge changesets that have already been merged.

You might run into some weird edge cases if you're doing some really tricky stuff, but even if you do it will be miles better than using SVN.

like image 21
Steve Losh Avatar answered Oct 27 '25 21:10

Steve Losh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!