git cherry-pick的注意事项
git cherry-pick的注意事項
對于多分支的代碼庫,將代碼從一個分支轉移到另一個分支是常見需求。
這時分兩種情況。一種情況是,你需要另一個分支的所有代碼變動,那么就采用合并(git merge)。另一種情況是,你只需要部分代碼變動(某幾個提交),這時可以采用 Cherry pick。
git cherry-pick命令的作用,就是將指定的提交(commit)應用于其他分支。
git cherry-pick <commitHash>commitHash為你在另外一個分支提交的分支id,具體的分支id可以在遠程倉庫中查看點擊,在倉庫的左側導航欄點擊commits即可看見該分支下的提交信息。
然后使用 git checkout切換到被轉移的分支下,本地使用git fetch 和git pull 獲取一下最新的代碼。然后切換到轉移的分支下,使用git cherry-pick 加提交id。
運行后可能出現
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 ’ or ‘git rm ’
hint: and commit the result with ‘git commit -c 3e86ed8’
時。 我們可以
git status git add . git commit -c 3e86ed8注意3e86ed8 為commit的id
總結
以上是生活随笔為你收集整理的git cherry-pick的注意事项的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 评论:UiPath Aces机器人流程自
- 下一篇: Arcgis Server 发布服务报错