您的位置:首页 > 其它

Use git cherry-pick

2013-02-21 12:13 281 查看
If you used commit -a -m to commit other branch's changes(branch A) to the current branch(branchB) by mistake, you want to put the last commit back branch A, so use

git cherry-pick logid

where, logid is the log id, which you can get from "git log"

The detail steps:

1. git checkout branch_B // go to branch_B

2. git log // Check the git log to get thelog id

3. git checkout branch_A // Got the branch A

4. git cherry-pick log_id // execute cherry-pick

5. git log // Check the log and you will find it works.

6. git checkout branch_B // go to branch_B

7. git reflog // you want to reset to the position before you commit, remember the reflog_id.

8. git reset --hard reflog_id // reset to the position before you commit

Over.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: