|
Re: is there any way to pull a subdirectory from a git repo using jGit [message #667509 is a reply to message #667447] |
Fri, 29 April 2011 09:13 |
Robin Rosenberg Messages: 332 Registered: July 2009 |
Senior Member |
|
|
On 2011-04-28 21.42, Wei Zhu wrote:
> Hi,
> I am new to jGIT. We have a pretty big Git repo and I am only interested
> in one of the sub directories. When I clone the git repo using JGIT, is
> it possible to only pull the particular subdirectory instead of the
> whole repo?
No.
Git works on the whole repo. There is a subtree merge, but that works
the other way, i.e. it pulls a complete tree from another repo into
a sub-directory of your repo.
To accomplish what you want to do, you hav to neutralise the parts
you do not wamt to merge, either before or after the merge.
EGit currently does not support neither case in a decent fasion,
so I suggest you use C Git for now.
# Alternative A: Prepare "theirs" before merge
git checkout source-branch
git checkout target-branch -- directories-or-files-you-do-not-want
git commit
git checkout target-branch
git merge source-branch
# Alternative B: Fixup after merge
git checkout target-branch
git merge source-branch
git checkout HEAD^ -- directories-or-files-you-do-not-want
git commit --amend
Alternative B will result in a "evil" merge, i.e. the result
is not a clean merge. I suggest you go with A which will get
you a better log of what happened.
-- robin
|
|
|
|
Powered by
FUDForum. Page generated in 0.02387 seconds