简体   繁体   中英

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?

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.

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.

Note that you should use Git completely instead of SVN to get the desired functionality. If you merely use git as a front-end to SVN (vai git svn ), this will likely cause things to not appear correct to SVN users.

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