我是github上的一個項目的粉絲(Slippy)。該項目的另一個分支(by kageroh)有一個提交,我想推送到原始項目,但維護人員不希望整個提交,只有一部分。只拿一部分的git commit,推送到github
我的理解是,我可以使用交互式重新綁定來僅提交部分提交,但我不應該這樣做,因爲它是已經存在於公共存儲庫中的提交。是否有辦法參與提交,並將其提交到原始回購,並保留作者的歸屬?或者我只需要複製我想要的更改並將它們置於我名下的新提交中?
我是github上的一個項目的粉絲(Slippy)。該項目的另一個分支(by kageroh)有一個提交,我想推送到原始項目,但維護人員不希望整個提交,只有一部分。只拿一部分的git commit,推送到github
我的理解是,我可以使用交互式重新綁定來僅提交部分提交,但我不應該這樣做,因爲它是已經存在於公共存儲庫中的提交。是否有辦法參與提交,並將其提交到原始回購,並保留作者的歸屬?或者我只需要複製我想要的更改並將它們置於我名下的新提交中?
我認爲選櫻桃和減少承諾是很好的。要設置提交的作者,只需使用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]>"
重寫公共分支的歷史是一個壞主意,但並沒有什麼神聖不可侵犯的個人提交這意味着你不能複製,修改和發佈在另一個分支。
您可能只需創建一個基於上游主設備的新分支,cherry-pick
您想要修改的提交,然後commit --amend
即可更改它。這應該保留作者身份。
承諾是櫻桃採摘所有的時間。見[我的問題](http://stackoverflow.com/questions/5147847/what-do-i-do-when-a-pull-request-is-cherry-picked)。 – 2011-03-09 12:49:27