开发者

git partial pull

I am maintaining a repository A.

Another contributor has cloned A to another repository B.

Later, the other contributor added files F, which is irrelevant to me,开发者_如何学Python into B.

Now I want to merge changes in B back to A, but without committing F. How to do so?


Fetch the head and cherry-pick from there.

git remote add jessica git://jessica.com/repo.git
git fetch jessica master
git cherry-pick 235a5
...


you could do:

git checkout <remote_branch> <paths>

where <paths> is the files that you actually want. this is easiest if the files you want are in separate directories to the files you don't, as you can use wildcards.

alternatively, try:

git pull --squash

this may be a bit manual, as you then have to go and delete the files you don't want before committing, but it is also the only way to do it if the files you don't want have been added as part of the same commit that changed files you do want.

the (fairly major) downside is that you lose the commit history of the remote branch.


The short answer is that you cannot "partially pull" with git.

However, you can pull the changes from B, and then use git-rebase(1) or git-filter-branch(1) to modify the commit(s) containing F before pushing to A. Keep in mind that this will change (relative to B) the hashes of the commit(s) you modify, so future merges attempted upon B will be less intelligent than usual.

Take a look at the Pro Git chapter on Rewriting History.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜