Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git partial pull

Tags:

git

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, into B.

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

like image 719
kennytm Avatar asked Jun 06 '10 06:06

kennytm


2 Answers

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.

like image 70
sml Avatar answered Sep 28 '22 21:09

sml


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
...
like image 33
wilhelmtell Avatar answered Sep 28 '22 23:09

wilhelmtell