问题

在本地master提交了一个commit(8d85d4bca680a5dbcc3e5cfb3096d18cd510cc9f),如何提交的test_2分之上?

方法

使用cherry-pick

用法

git cherry-pick <commit_id>

举例

git checkout test_2
git cherry-pick 8d85d4bc

如果顺利,那么已经提交test_2版本。

如果出现冲突,如

$ git status
On branch test_2
Your branch is up-to-date with 'origin/test_2'.
You are currently cherry-picking commit 0e82d79.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)

        both modified:   test_1.txt

解决冲突,然后提交

$ git commit -m 'test_1.txt'
[test_2 55e0fba] test_1.txt
 Date: Tue Aug 16 13:41:06 2016 +0800
 1 file changed, 1 insertion(+), 1 deletion(-)

$ git pull
Already up-to-date.

$ git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 295 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To git@******/git_test.git
   bba03ee..55e0fba  test_2 -> test_2

 

转载于:https://www.cnblogs.com/kaituorensheng/p/5776149.html

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐