I want to pull from and push to only a subdirectory of a git repository. Here is an example of what I want to achieve:
Let's say, I have a repository, containing two folders A
and B
(they are top-level folders, if that matters). I want to work and push changes into B
only, while others are working on A
and maybe even on B
as well. Because I want to commit my changes back, I can't put A
in the .gitignore
file, nor I can use git rm -rf --cached A
, since A
is needed by others, however, I know, I will never touch any of the files it contains, and I simply don't want to store the unnecessary files of it. I can't use submodules
either, as I don't want to change the original repository, nor I want to maintain a secondary one.
So my questions are: is this even possible; and if so, how can achieve this?
You can't pull or push from a specific folder in your repo. You pull or push on a branch.
Have you considered making a branch and switching to it when working on B
, this way, you won't pollute your team's work made on A
?
You could even rebase your branch if you want to retrieve the work made by your team on the main branch to your own branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With