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 messageGo to next 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
Re: is there any way to pull a subdirectory from a git repo using jGit [message #1586810 is a reply to message #667509] Tue, 27 January 2015 02:28 Go to previous message
rupert THURNER is currently offline rupert THURNERFriend
Messages: 5
Registered: July 2009
Junior Member
(how) would it be possible to later on merge another subtree of the same source-branch?
Previous Topic:Java Project Git Tag Changed From master to NO-HEAD
Next Topic:How to do "git log --oneline --decorate" in JGit
Goto Forum:
  


Current Time: Sun Aug 30 05:54:04 GMT 2015

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

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