Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit » is there any way to pull a subdirectory from a git repo using jGit
is there any way to pull a subdirectory from a git repo using jGit [message #667447] Thu, 28 April 2011 19:42 Go to next message
Wei Zhu is currently offline Wei ZhuFriend
Messages: 1
Registered: April 2011
Junior Member
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?

Thanks.
-Wei
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 Go to previous message
Robin Rosenberg is currently offline Robin RosenbergFriend
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
Previous Topic:Missing requirement while installing EGit Mylyn GitHub
Next Topic:Problem in adding Pramati as Eclipse Server
Goto Forum:
  


Current Time: Fri Nov 28 09:58:10 GMT 2014

Powered by FUDForum. Page generated in 0.02150 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software