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.
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.
相关文章推荐
- git cherry-pick 把提交到A分支的部分commit 再提交到B分支上
- git cherry-pick. 如何把已经提交的commit, 从一个分支放到另一个分支
- 显示git提交日志时如何忽略cherry-pick的提交
- Git cherry-pick后再merge出现一个“奇怪”的现象
- Git日常采坑系列- Tag&&cherry-pick
- git 应用 cherry-pick
- git stash 和 git cherry-pick
- Git cherry-pick 和 rebase 的混合用法
- git cherry pick
- Git知识总览(五) Git中的merge、rebase、cherry-pick以及交互式rebase
- svntogit git rebase git cherrypick
- git cherry-pick
- git命令cherrypick
- Git笔记(三)——[cherry-pick, merge, rebase]
- Git Cherry-pick
- git cherry-pick
- Git知识总览(四) git分支管理之rebase 以及 cherry-pick相关操作
- git cherry-pick简介
- git cherry-pick. 如何把已经提交的commit, 从一个分支放到另一个分支
- git merge vs rebase vs cherry-pick