Reputation: 4766
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.
Upvotes: 9
Views: 4038
Reputation: 1
On Windows, you can achieve the same result by doing the following:
Supposing you have the Project A in the folder'C:\webstack\Project A' and the Project B in 'C:\server\Project B'. Files of each project are already there respectively. Please note in this point it doesn't really matter what's a path to each folders, unless they are in a normal filesystem on a local, phisical drive(s)
Create a folder for your GIT project; say 'C:\repos\git-project-A-B'
3.In Windows cmd type:
cd 'C:\repos\git-project-A-B\'
Now you are in you destined GIT working directory. Time to create hard-linked directory junctions for Project A folder (directory)
C:\repos\git-project-A-B> mklink /J /H "C:\webstack\Project A"
and the same for Project B:
C:\repos\git-project-A-B> mklink /J /H "C:\server\Project B"
If the operations in the point 4 have been done correctly, by typing the command dir /all in the working directory you should see at least two hardlinks (junctions):
(date) (time) Project A [c:\webstack\Project A]
(date) (time) Project B [c:\server\Project B]
Now, the fun part! You can work normally in each projects folders, but you initialize you GIT repo only in C:\repos\git-project-A-B. From now on, you can do as follows
C:\repos\git-project-A-B> git add "Project A"
and
C:\repos\git-project-A-B> git add "Project B"
and then commit changes, invoke status reports, repo logs etc.
It works like a charm!
Upvotes: 0
Reputation: 332776
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
Upvotes: 11
Reputation: 239240
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.
Upvotes: 4