10

我正在使用一些没有使用 SCM 的代码+并以所有项目文件的形式接收偶尔的更新,尽管只有其中一些只做了一点更改。到目前为止,我只是将自己的更改放入 git repo 并通过手动git add -p会话解决了这些“更新”,随着我自己的更改(尚未确定发布的更改)的数量越来越多,这变得越来越烦人,由于幸运的是我git commit --author "the others"为上述“补丁”做了,我想知道:

一个作者的所有提交如何被分离到一个新的分支中?

(我不介意在这种情况下重写历史,repo 仅供我使用)

理想的解决方案将包括在每个“补丁”之后将其他分支合并到我的分支中,但现在最后的最终合并可能就足够了。


+是的,绝地确实觉得你在那里畏缩

4

2 回答 2

7

我最近为某人做了这个:

git checkout -b other_work <sha1_of_where_to_rebase>
git log --reverse --author=others --format=%H <sha1_range> | xargs -n 1 git cherry-pick

希望这可以帮助

于 2011-04-21T07:57:04.400 回答
2

我不太了解您在做什么,但是您用第三方代码库描述的问题被称为“供应商分支”。这是我将如何处理它:

为第三方版本创建一个分支,例如vendor. 我假设您的分支称为master. 当他们发布新版本时,您可以执行以下操作:

git stash # If you have any uncommitted files
git checkout vendor
tar -xzvf [new files]  # This might be unzip or whatever, rather than tar
git commit -am "Version xxx from upstream"  # Adjust commit message to suit
git checkout master
git merge vendor   # Bring changes into your branch (you could use rebase here if you prefer to keep all your changes on top of all their changes)
git stash pop # Restore your uncommitted files

附言。而不是git add -p,我会使用git gui. 一开始我对使用 gui 持怀疑态度,但我不能没有git guigitk现在(或gitx在 mac 上)。

于 2012-05-14T13:20:55.843 回答