1

在做一些 git rebase 时,我让自己扭曲了。在下图中,我想stable指出提交6016f6,并且我希望所有其他“以上”6016f6提交都消失。换句话说,我有BEFORE但我想要AFTER

前:

*   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

后:

*   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

(注意:为了节省一些空间,我截断了哈希并删除了作者行。)

4

2 回答 2

0

git checkout stable, git cherry-pick 6016f6. 如果我理解正确,只需将额外的提交挑选到stable分支上,你就会被设置。

于 2013-04-27T20:53:42.510 回答
0

你做了最困难的部分——设想你想要树的样子。现在只需移动分支标记以匹配它:

$ # Move 'stable' branch marker up
$ git checkout stable
$ git merge --ff-only 6016f65
$ git push origin stable

现在,如何处理 'fixpaths' - 或者拉回远程 'fixpaths' 以匹配您的本地(以下两种方式),或者只是删除本地和远程分支,因为您已经完成了它(下面的最后一种方式):

$ # 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
于 2013-04-27T21:23:40.347 回答