Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single Git repo with directories in multiple locations

Tags:

git

Git newb question here. Coming from SVN, where I can have multiple branches checked out all of the place ("/www/project1", "/users/project2", etc.) but all live in the same repository. Each branch has it's own commits, revisions, etc. You guys know the deal.

Is there a similar method to this in Git, where you can have directories/branches in a single repo spread out all over place? Again, sorry for the newb question. Trying to get a bead on this. Thanks a bunch for any insight that can be provided here.

like image 733
Ryan Palmer Avatar asked Jan 15 '13 20:01

Ryan Palmer


People also ask

How do I add multiple folders to a git repository?

If you drag multiple Git folders into GitHub Desktop at the same time, each folder will be added as a separate Git repository.

Can a Git repo have multiple projects?

Yes. You can put multiple projects in one Git repository but they would need to be on different branches within that repo. The Git console in ReadyAPI gives you the ability to create or switch branches from the UI. More information on the Git integration can be found here in the documentation.

How do I clone a repo with all branches?

To clone a branch in a git repository, start by cloning the master repository using the git clone command. Once complete, navigate into the repo directory. The command will show the branches that are available in the local repository. To view even the remote branches, use the -a flag.


1 Answers

Normally, as checkout and merging process are really fast, developers using Git keep all branches and just switch between them in the same folder. The SVN branching system is very slow, and not really good, that's why they usually kept them in a different folder.

It is possible to checkout a branch to a different folder:

git --work-tree=<path to target> --git-dir="<path from source>" checkout <reference-name>
# example:
git --work-tree=. --git-dir="/base-repo/.git" checkout master

Note, though, that this new folder won't be versioned. To keep it versioned, you could re-clone the repo in another folder:

git clone path/to/local/repo/.git

Note that in git, each clone is the full repo (the exact same thing there is on your server and in your other folder). Each clone is completely independent and can push/pull from any other repo.

Hope this helps!

like image 104
Simon Boudrias Avatar answered Oct 19 '22 02:10

Simon Boudrias