简体   繁体   中英

git conflicts using branches

In my project, for example I have two branches(let it be br_1 and br_2 ). In each branch I make some issues. I have some problems during this:

for some issue (on br_2 ) I need to rename one of the table column. So, everything ok, I made upgrade script(using Magento), it renamed column, works fine. The problem appeared when i switched to another branch.(In this branch my old script was asked to old name of column).

So, now, on br_1 there is an error.

First way is to rename table column back, and do what you want on this branch. But after that I need to do it again, and again, before I will merge all branches to master.

Second way is to change in the php srcipt on br_1 the name of old column into the new.

Are there more clean way to resolve it?

You can either merge br_2 into br_1 , which will take all the history (commits) in br_2 missing from br_1 and merge them on top of br_1 's changes. Or, if your fix in br_2 is contained in a single commit (like [548662a4] Fix name of table column ), you can cherry-pick your commit into br_1 .

First option (takes all history from br_2 ):

git checkout br_1
git merge br_2
// Potentially fix and merge conflicts, and re-commit

Second option (takes a single commit from br_2 ):

git log br_2
// commit 548662a48154cf741649892cefc421135c65caf1
//   Fix name of table column

git checkout br_1
git cherry-pick 548662a4
// Potentially fix and merge conflicts, and re-commit

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