Y
Y
yeleleo2013-01-26 12:53:06
git
yeleleo, 2013-01-26 12:53:06

Working on a single file in Git using ?

There is a need to provide a person with one file / one folder / group of folders from the entire git repository for revision.
For some reason, you can't let $ git clonethe whole project be done.
Changes will be applied using $ git format-patchand, accordingly, it should not contain changes to other files.
How can you transfer a folder to work with another user (without access to the repository at all) and then get a working and quite usable *.patch from him ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2013-01-26
@jcmvbkbc

If he needs a history of changes, make a filtered clone of your project, in which leave only the necessary (I have path-to-preserve) directories in the necessary branches (I have HEAD, i.e. the current one):

git filter-branch --tree-filter "find -not \( -path './path-to-preserve*' -o -path './.git' -o -path './.git/*' \) -delete" --prune-empty HEAD

and already give this clone.
If the history is not needed, create a repository from this single directory and give it away.
Changes will be applied using $ git format-patch and should not contain changes to other files.

Probably, after all, git am will apply the changes. Nothing, however, will prevent another user from creating files outside of the directory given to them and including them in their patches. On the other hand, these patches can be compiled into a new repository, which is also filtered.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question