在做一些git rebasing时,我让自己扭曲了。在下面的图表中,我希望stable
指向提交6016f6
,我希望所有其他提交“高于”6016f6
的提交消失。换句话说,我有BEFORE
,但我想要AFTER
:
BEFORE:
* commit 725b5f (origin/fixpaths)
|\ Merge: 6016f65 e91c3aa
| | Date: Sat Apr 27 07:04:05 2013 -0700
| |
| | Merge branch 'fixpaths' of wayfare.example.org:/modules/base into fixpaths
| |
| * commit e91c3a
| | Date: Fri Apr 26 16:49:39 2013 -0700
| |
| | fix permissions on many cron files
.
.
.
| * commit 160460
| | Date: Fri Apr 26 14:35:14 2013 -0700
| |
| | module paths cleanup for dns.pp
| |
| * commit ecbfd6
| | Date: Fri Apr 26 14:23:30 2013 -0700
| |
| | fix module paths in cron base module
| |
* | commit 6016f6 (HEAD, fixpaths)
|/ Date: Fri Apr 26 14:23:30 2013 -0700
|
| Change module paths to work with base module.
|
* commit 88d0bc (origin/stable, stable)
| Date: Mon Apr 22 15:51:44 2013 -0700
|
| committing everything for branch stable
|
| * commit 9baf5a (tag: release/latest, origin/master, origin/HEAD, master)
|/ Date: Wed Apr 24 14:47:23 2013 -0700
|
| Fix permissions on all of the cron jobs
AFTER:
* commit 6016f6 (HEAD, stable, origin/stable)
|/ Date: Fri Apr 26 14:23:30 2013 -0700
|
| Change module paths to work with base module.
|
* commit 88d0bc
| Date: Mon Apr 22 15:51:44 2013 -0700
|
| committing everything for branch stable
|
| * commit 9baf5a (tag: release/latest, origin/master, origin/HEAD, master)
|/ Date: Wed Apr 24 14:47:23 2013 -0700
|
| Fix permissions on all of the cron jobs
(注意:为了节省一些空间,我已经截断了哈希并删除了作者行。)
答案 0 :(得分:0)
git checkout stable
,git cherry-pick 6016f6
。只是樱桃 - 选择额外的提交到stable
分支,如果我理解正确,你将被设置。
答案 1 :(得分:0)
你做了很难的部分 - 想象你希望树看起来像什么。现在只需移动分支标记以匹配它:
$ # Move 'stable' branch marker up
$ git checkout stable
$ git merge --ff-only 6016f65
$ git push origin stable
现在,如何处理'fixpaths' - 要么拉回远程'fixpaths'以匹配你的本地(以下2种方式),要么删除本地和远程分支,因为你已经完成了它(下面的最后一种方式):
$ # Delete the remote fixpaths and repush the local one
$ git push origin :fixpaths
$ git push origin fixpaths
$ # Force the remote 'fixpaths' branch marker backward to your local 'fixpaths'
$ # (Note: generally push -f is inadvisable unless you understand what you are doing)
$ git push -f origin fixpaths
$ # Or else delete fixpaths because you don't need it anymore
$ # Caution: this will 'delete' the local and remote branches
$ git branch -d fixpaths
$ git push origin :fixpaths