Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two different Git repo in same directory

Tags:

git

I want to maintain two different git repos. The repos should stay in the same root directory. How to achieve it?

What I'm want is: to manage two repositories that differ slightly. Can I have two completely different repositories in the same directory?

like image 618
Shafiul Avatar asked Jan 08 '12 15:01

Shafiul


People also ask

Can I have multiple Git repositories in one folder?

Yes, it is possible to have two git repositories in one directory.

How do I add a second repository to GitHub?

In the command line, navigate to the directory where you would like to create a local clone of your new project. To create a repository for your project, use the gh repo create subcommand. When prompted, select Create a new repository on GitHub from scratch and enter the name of your new project.

Can we use multiple Git repos in a single Jenkins job?

Checking out more than one repo at a time in a single workspace is possible with Jenkins + Git Plugin (maybe only in more recent versions?). In section "Source-Code-Management", do not select "Git", but "Multiple SCMs" and add several git repositories.


1 Answers

You can achieve this by adding using one of these two options on the git command itself:

git --work-tree=where/my/code/is --git-dir=some/path/to/my/.git status

This would allow you to have 2 separate repos share the same working folder.

However you should be able to get what you need by using one repo with multiple branches and perhaps only push certain branches to multiple remotes.

like image 135
Adam Dymitruk Avatar answered Sep 28 '22 06:09

Adam Dymitruk