2011-03-09 30 views
3

我是github上的一个项目的粉丝(Slippy)。该项目的另一个分支(by kageroh)有一个提交,我想推送到原始项目,但维护人员不希望整个提交,只有一部分。只拿一部分的git commit,推送到github

我的理解是,我可以使用交互式重新绑定来仅提交部分提交,但我不应该这样做,因为它是已经存在于公共存储库中的提交。是否有办法参与提交,并将其提交到原始回购,并保留作者的归属?或者我只需要复制我想要的更改并将它们置于我名下的新提交中?

+0

承诺是樱桃采摘所有的时间。见[我的问题](http://stackoverflow.com/questions/5147847/what-do-i-do-when-a-pull-request-is-cherry-picked)。 – 2011-03-09 12:49:27

回答

7

我认为选樱桃和减少承诺是很好的。要设置提交的作者,只需使用git commit --author="The Original Author <[email protected]>"

举个例子,如果f414f3l是承诺要减少,我可能会做到以下几点:

# Make sure you're on the branch you want to create the new commit on: 
git checkout master 

# Now cherry-pick the commit, but only stage the changes: 
git cherry-pick -n f414f3l 

# Choose which hunks you want to unstage interactively, using the 's' 
# option to split them where necessary. (Or using the 'e' option for 
# complete control over what patch to unstage.) 
git reset -p 

# When you commit, the commit message should be preserved: 
git commit --author="The Original Author <[email protected]>" 
0

重写公共分支的历史是一个坏主意,但并没有什么神圣不可侵犯的个人提交这意味着你不能复制,修改和发布在另一个分支。

您可能只需创建一个基于上游主设备的新分支,cherry-pick您想要修改的提交,然后commit --amend即可更改它。这应该保留作者身份。