Reputation: 813
Is it possible to clone the same repository multiple times with Github for Windows? The reason I ask is I want to clone the Laravel framework multiple times, once for each project I'm using it for.
Upvotes: 17
Views: 23064
Reputation: 81
The accepted answer from @baldrs (cloning multiple times) works, but is not the way it is thought to be.
Git has a feature called worktree
, that's what should be used here:
git clone --bare <repo> ./repo.git
cd ./repo.git
git worktree add ../<directory> <hash_of_master>
git worktree add ../<directory_2> <hash_of_master>
......
git worktree add ../<directory_N> <hash_of_master>
This is the better way to go, especially when it is a large repository, as the git object database only gets cloned once and every worktree uses the same database.
Using this approach, it is no problem to switch branches individually if need be, don't worry. The only thing is that one branch (name) can only be checked out once, but simply use the hash (to do detached HEAD) so it can be checked out multiple times.
See git documentation for details: https://git-scm.com/docs/git-worktree
Upvotes: 2
Reputation: 2161
It is possible, and it is simple enough
In git bash:
git clone <repo> <directory>
git clone <repo> <directory_2>
.............................
git clone <repo> <directory_N-1>
git clone <repo> <directory_N>
Repo is your repository URL, and all those directory[N] are your desired directory names
Also, why not just make a copy of an already cloned repo to another directory?
Upvotes: 18