Skip to main content



      Home
Home » Eclipse Projects » EGit / JGit » 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 15:42 Go to next message
Eclipse UserFriend
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 05:13 Go to previous messageGo to next message
Eclipse UserFriend
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] Mon, 26 January 2015 21:28 Go to previous message
Eclipse UserFriend
(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:egit ssh failure
Goto Forum:
  


Current Time: Tue Jul 22 17:43:01 EDT 2025

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

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

Back to the top