1

How can I create a local repository and then create another local repository by cloning the first one?

I would like to do it for experimentation with git pull and git push.

Roman
  • 124,451
  • 167
  • 349
  • 456
  • Why do you need a separate repo to test `git push` and `git pull`? Wouldn't creating a test branch somewhere be just as effective? – Tim Biegeleisen Dec 21 '17 at 10:29
  • 1
    When you clone from a remote repository, you specify the url as `git clone `. The url could be a path to a local repository. – ElpieKay Dec 21 '17 at 10:30
  • [\[from duplicate\]](https://stackoverflow.com/questions/4941090/cloning-git-repository-locally#comment128759182_4941090) Note that your (2nd) local clone will only see the local branches of the 1st local repo. It will _not_ see any remote branches of the latter, unless you also add the remote of the 1st repo to the list of remotes of the 2nd repo — one remote for the 1st local repo and one 'truly' remote for the repo not-on-mac. Stashes also won't be in the 2nd repo. If you want to experiment with the same remote, stash, git config etc. you might want to just copy the 1st repo directory. – PDK Jul 07 '22 at 14:12

1 Answers1

20

Just put path to repo you want to clone

git clone /home/my_user/my_project
atomAltera
  • 1,702
  • 2
  • 19
  • 38
  • 1
    though this works fine, the origin will point to the local repo, so extra tuning is needed – AntonK Nov 25 '22 at 16:53