使用git cherry-pick 解决冲突,commit changes to other branch and resolve conflict
2014-04-02 14:23
417 查看
Check out the branch you want to cherry-pick from
Harley bugfix branches have been added to the main Koha git repo, so you don't have to add a new remote repo. There wecan find a branch for
Bug 3475.
git checkout ptfs/Bug3475
git will warn you "You are in 'detached HEAD' state," but we're just checking out the branch to check the log of commits.
Find the commits to cherry-pick
git log --pretty=oneline
Outputs:
3e86ed85fd595c99bd73292553ef1d09d95e53ae Added Copy Patron button to circ-toolbar ab97540637691bd73581fed3828c164191c9e0bb Cleared the extended patron attributes from being copied when adding 04566389ae36651daf3dfa117a1088d594632370 Added a copy patron link from moremembers page 595e6a190b9e90cf1371ac0b853999286948c852 Merge branch 'Bug3789' into ptfs-master fa59e2f7480dc63d7824c5587c82c3f6df3b96ae Bug 3789 Set off shelving location in staff and OPAC title display 38ddef75baeb3f3bd4487cfc25340be9dc2baa4c Merge branch 'Bug3514' into ptfs-master 5d3b6945764cd2a292f822963feca9cf12776605 Extends Bug 3514 syspref to control whether the Return column is acti 279dab8f631ba7aa44b8a35da7f5d43b24d69924 Bug 3514 syspref to control whether the Return column is active in Pa 1f1540f0218d5ad8348700f74c60ad7ca95625b3 Bug 4215 OPAC "Search for title in" can fail with trailing slashes in 6e0cc4061e82c2f861aef1a0db584502c9a3268e Merge branch 'Bug4243' into ptfs-master
Looking at the history in the branch we have to find the earliest change relevant to the feature we want to cherry-pick. If we're lucky we'll be looking at a clean branch that diverges from origin/master for that particular feature/bugfix. In this example
we have to make a guess at where the Bug 3475 fixes begin. Probably with 'Added a copy patron link from moremembers page'
Create a clean new branch to work in
Open another terminal window, leaving this one open to the git log output for reference, and create a new branch based on master to cherry-pick into:git checkout -b bug-3475 origin
Start cherry-picking
Then we'll start the cherry-pick process with the earliest commit relevant to Bug 3475:git cherry-pick 04566389ae36651daf3dfa117a1088d594632370
In this case the commit applies cleanly and we can proceed to the next ones:
git cherry-pick ab97540637691bd73581fed3828c164191c9e0bb git cherry-pick 3e86ed85fd595c99bd73292553ef1d09d95e53ae
Resolve conflicts
On the last one we hit a snag:error: could not apply 3e86ed8... Added Copy Patron button to circ-toolbar hint: after resolving the conflicts, mark the corrected paths hint: with 'git add <paths>' or 'git rm <paths>' hint: and commit the result with 'git commit -c 3e86ed8'
Unfortunately it doesn't tell us what the problems are, so we type:
git status
On branch bug-3475 Your branch is ahead of 'origin/master' by 2 commits. Unmerged paths: (use "git reset HEAD <file>..." to unstage) (use "git add/rm <file>..." as appropriate to mark resolution) both modified: koha-tmpl/intranet-tmpl/prog/en/includes/circ-toolbar.inc
Now we can see that circ-toolbar.inc is the file with the conflict. Open the file, look for the standard "<<<<<<< HEAD" marker and edit as necessary. When finished:
git add koha-tmpl/intranet-tmpl/prog/en/includes/circ-toolbar.inc
And then:
git commit -c 3e86ed8
Notice we're following the instructions for git commit as output in the conflict message. This will launch your commit message editor, but you can save without making changes. If this is the last commit to cherry-pick, you're done! It's time to
test and make any corrections which are necessary.
相关文章推荐
- Git出现error: Your local changes to the following files would be overwritten by merge: ... Please, commit your changes or stash them before you can merge.的问题解决(Git代码冲突)
- svn 冲突解决 Decide how to resolve conflict on xxxx.java
- Git出现error: Your local changes to the following files would be overwritten by merge: ... Please, commit your changes or stash them before you can merge.的问题解决(Git代码冲突)
- Git冲突:commit your changes or stash them before you can merge. 解决办法
- Git冲突:commit your changes or stash them before you can merge. 解决办法
- ASP.NET AJAX DropShadow 控件的一个BUG和解决方法(a bug of DropShadow and solution to resolve)
- 当出现no changes added to commit时如何正确使用git提交命令
- 解决办法: Cannot resolve the collation conflict between "Japanese_CI_AS" and "SQL_...
- Git冲突:commit your changes or stash them before you can merge. 解决办法(转)
- 解决SQL 的 Collation 问题:Cannot resolve collation conflict for equal to operation.
- Git冲突:commit your changes or stash them before you can merge. 解决办法
- 使用Mono Cecil 动态获取运行时数据 (Atribute形式 进行注入 用于写Log) [此文报考 xxx is declared in another module and needs to be imported的解决方法]-摘自网络
- sql server 小技巧(6) Cannot resolve the collation conflict between "Latin1_General_CI_AI" and "Chinese_PRC_CI_AS" in the equal to operation
- 解决在一个topic branch上有多个cherry pick commit修改后repo upload 失败问题
- 遇到no changes added to commit时如何正确使用git提交命令
- 使用android工程作为类库Unable to resolve superclass of L问题的解决
- 使用android工程作为类库Unable to resolve superclass of L问题的解决
- 使用git commit命令时遇到 fatal: Unable to create index.lock File exists 错误的解决办法
- 当出现no changes added to commit时如何正确使用git提交命令
- Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Chinese_PRC_CI_AS" in the equal to operation.