How to include two different folders into the same git project?

Hey, i am working on two programs at the same time. Assume A and B are two different folders in different directories. Is it possible to have them both be a part of the same git project? Because i use data from A as input for B, but since A is a web app, i’ve put it in public_html while B is in a different folder.

  • Searching for commits which reference a given object
  • Check if there is a newer version of my local file in Github, with R
  • Suggestions on optimizing the EGit on Eclipse
  • A good way to backup code with git
  • git svn fetch & rebase broken after connection failure
  • Git merge fails when file has been moved in both branches
  • What should I use for git user.name?
  • How to determine if Git merge is in process
  • SmartGit won't authenticate with ssh
  • Pull from github without authentication every time
  • How do I move the past n commits to main, into a separate branch, with git?
  • git cherry-pick -x default
  • 2 Solutions collect form web for “How to include two different folders into the same git project?”

    Create a git project with the two directories, put it somewhere else, and then just create symlinks in the two locations that you need the two folders.

    $ ls -a myproject
    . .. .git A B
    $ ln -s myproject/A A
    $ cd public_html
    $ ln -s ../myproject/B B
    $ cd ..
    $ ls 
    myproject A public_html
    $ ls public_html
    B
    

    Short answer, you can’t. Make each a separate git repository. Two different programs don’t belong in the same repository anyways.

    Long answer: The only way would be to create a git repo higher up in the file system at the point where the two directories share a common ancestor. This might even be the root of your file system. You could add each of the two project directories to the repo and specify everything else in .gitignore. This is obviously less than ideal.

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