Reputation: 835
I'm new to git, I'm interested in keeping update a directory in a git repository, I'm cloning the repository and running filter-branch on it:
git clone http://url.git
cd repository
git filter-branch --subdirectory-filter directory-I-m-interested
This is awesome, the repository now have the contents of the directory-I-m-interested in the root path, however I'm still not sure how to keep the files on this directory in sync with the original project.
I've tried with the following commands:
git fetch
git cherry-pick hash_taken_from_last_command
and I get the following error:
error: could not apply a0ede43... 2
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
Probably I'm just executing non sense, any hints?
Upvotes: 0
Views: 316
Reputation: 706
It sounds like what you want is a sparse checkout. Look here
http://briancoyner.github.io/blog/2013/06/05/git-sparse-checkout/
for instance. It restricts the working copy (checked out files) in git to a subset of the original git repository. You can follow the original as normal with git but just see the part of it you are interested in.
Upvotes: 1
Reputation: 8345
Git offers pretty strong guarantees about the integrity of the repository. Running git filter-branch
is a deep surgical operation that results in a completely new repository with all the commit checksums recalculated etc. You have in fact rewritten the whole history of the project, so during fetching and merging changes from the old repository Git will correctly complain that it doesn't recognize the new, changed history of the repository. There's no way for Git to have split personality and at the same time remember and forget about the rest of the directories.
As you say, you're new to Git, so please reconsider if you really need to do such deep and intrusive surgical operations on your repository.
Upvotes: 0
Reputation: 8819
You are executing non sense. I believe you are looking for functionality of svn
as you are only wanting to use one sub-directory. With the local repository after the above git filter-branch
command, a git push
probably would fail and a git push -f
would wipe away the other directories of the repository.
Upvotes: 0