只接受git commit的一部分,推送到github

Ned*_*der 3 git github rebase

我是github(Slippy)项目的粉丝.该项目的另一个分支(由kageroh)有一个我想要推送到原始项目的提交,但维护者不希望整个提交,只是它的一部分.

我的理解是,我可以使用交互式变基只采取部分提交,但我不应该因为它是已经在公共存储库上的提交.有没有办法参与提交,并将其拉到原始回购,作者的归属完整?或者我只需要复制我想要的更改并将它们放入我名下的新提交中?

Mar*_*air 7

我认为挑选并减少提交是件好事.要设置提交的作者,只需使用git commit --author="The Original Author <his@address>".

举个例子,如果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 <his@address>"
Run Code Online (Sandbox Code Playgroud)