git subdirectory which is ignored

I have a project named ‘myproject’ which is version-controlled by git. It has a subdirectory named ‘data’ which is gitignored.

Can I ‘git init’ for data directory and manage it as a separate git tree?
I tested it and it seems to work.
But I am not sure if that’s a good practice and has potential problems.

  • How to get a detached repository working
  • Git rebase tries to apply changes to wrong file
  • Telling if a Git commit is a Merge/Revert commit
  • How do you mirror a specific branch to a branch in another repository?
  • How to make Git only ask password when push to remote repository
  • TFS2015: How to set two different build definiton to use the same local repository (git)?
  • Why doesn't my Git status show me whether I'm up-to-date with my remote counterpart?
  • Best workflow using node.js npm and git
  • triple-dot notation for git diff works strangely
  • How to use expect and git clone?
  • Sphinx generated html pages look different when pulled to a NAS drive git repository
  • Cannot make git diff use diff.external for external diff tool
  • 2 Solutions collect form web for “git subdirectory which is ignored”

    Yep, that should be fine. I’ve done that many times before, with no problems.

    If the parent repository depends on the ‘data’ repository being a specific version, you might want to consider git submodules. This will allow the parent repository to point to a specific commit of the ‘data’ repository. Even if the two are compatible now they may not be in the future.

    I don’t have much detail on your use-case and how ‘myproject’ relates to ‘data’, so submodules may over-complicate things for you.

    Git Baby is a git and github fan, let's start git clone.