问题
I am working in software vendor company. My team needs to submit code to client's git repository and we conduct code review prior submitting code in which we will have all the comments and code correction.To setup this flow, I want to point parent project directory to multiple git repositories
How can I set up two git repositories in the same directory on osx. I am using sourcetree as git tool
回答1:
You can set up multiple push URLs to a single remote.
Origin is default remote in a git project:
git remote -v
origin git@git.company.es:group1/project.git (fetch)
origin git@git.company.es:group1/project.git (push)
Then you can add more push url to your remote.
git remote set-url --add --push origin git@git.other.es:test/project.git
Now you should show two (push) URLs and one (fetch) URL. Something like this: git remote -v origin git@git.company.es:group1/project.git (fetch) origin git@git.company.es:group1/project.git (push) origin git@git@git.other.es:test/project.git (push)
Pushing to this remote will push to both upstreams simultaniously. Fetch and pull from this remote will still pull from the original repo only.
Also you can keep the original remote (origin) and create an alternative remote and use it to push both repositories:
git remote add both
git remote set-url --add --push both
git@git.company.es:group_1/project.git
git remote set-url --add --push both git@git.other.es:test/project.git
And your remote configuration will be:
git remote -v
origin git@git.company.es:group1/project.git (fetch)
origin git@git.company.es:group1/project.git (push)
both git@git.company.es:group1/project.git (fetch)
both git@git.company.es:group1/project.git (push)
both git@git@git.other.es:test/project.git (push)
And now you can decide which remote you want to use in different situations.
来源:https://stackoverflow.com/questions/47910773/single-directory-pointing-to-multiple-git-repositories