0

Situation We have Git a repo with multiple top-level directories - gradle multiple module project.

Problem One dirrectory has a lot of files, and in my work I don't need them at all. I don't want them to be on my disk, I don't want my IDE scan them accidentally, and by the most part - I don't want them to slow down any git operations like pull and make me toss here and there conflicting changes (removal of this dir).

What will be the perfect situation I wish to exclude this dir from ANY awarness that it exists (locally). So I could know that it exists only by looking to remote. So I could not see it on disk, and pull/checokut/commit/merge/push and other Git operations would be just like we don't have this directory at all.

Comment I did try git ignore, didn't help.. Thanks in advance for solving my pain!

SlavaL
  • 41
  • 3
  • Does this answer your question? [How do I clone a subdirectory only of a Git repository?](https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository) – phd Apr 17 '20 at 11:01

1 Answers1

2

You can move this folder to submodule.

Git submodule: a construct within Git that enables you to keep a separate Git repository as a subdirectory within an existing repository. This effectively keeps two separate repositories linked together within a project.

# adds a submodule
git submodule add git@github.com:robconery/logging.git logging
git submodule init

# cloning repository with submodules
git clone ...
git submodule init
git submodule update
ceth
  • 44,198
  • 62
  • 180
  • 289
  • So I can move only annoying directory to submodule and my repo will not be affected by it? Or I need to move my work subdirs (all the other ones) to separate submodule too? – SlavaL Apr 19 '20 at 10:05
  • You can move only one folder to git submodule. – ceth Apr 19 '20 at 10:25