2

I want to use an existing project as a starting point for a new project by copying or cloning it.

There are at least two ways of doing this.

Method 1: Copy it.
cp -R /path/to/source /path/to/dest

and

Method 2: Clone it.
git clone /path/to/source

What are the relative advantages and disadvantages of each approach compared to the other? Or do they both produce essentially exactly the same result?

2
  • 4
    Well, cp -R https://github.com/stuff won't work. Commented May 9, 2016 at 6:19
  • @PhilipKendall: Understood. Aside from that, though, are there any differences?
    – Mowzer
    Commented May 9, 2016 at 6:46

2 Answers 2

6

Copying copies the working copy, any untracked files, and any local configuration along with the actual repository.

Cloning doesn't, but it sets up the origin remote with a tracking branch.

Use copying if you want to duplicate your repository so that all remote operations work the same. Use cloning if you want to create a subordinate repository to your original.

3

This is not strictly an answer to you question, but if you want to start a new project, do you really want to copy all the history, branches, etc from the old project?

If you just want a working template, say to get the structure of the project as a starting point, but it should have no other ties to the original, then clone the repo but delete the .git folder and run git init again to start fresh.

1
  • From the poster's intention, it shows that the project would be a template so your comment makes more sense.
    – icasimpan
    Commented Sep 24, 2017 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.