Cloning a repository without making it the origin remote

Andrew Grimm picture Andrew Grimm · Feb 12, 2010 · Viewed 13.9k times · Source

I'm cloning a git repository from a computer that's going to be wiped.

Is it possible to clone a repository without making the original repository origin/master? Or do I need to clone it, and then delete the remote branch (which is done with git remote rm origin)?

Edit: The repository has only one branch, and no tags.

Answer

Jess Bowers picture Jess Bowers · Feb 12, 2010

It is not necessary to make the original repository the "origin" remote to clone the master branch.

On the new machine, create a new repository:

git init foo

Then pull the old repository into the new one, without creating a remote:

cd foo
git pull <reference to old repository>

However, it should be noted that the easiest way to save off a repository would be to just zip the repository's directory up and move the files to a new machine. That will preserve any and all remotes, tags, etc.

As noted below, when copying the repository, be careful when going from case-sensitive file systems (eg. Linux, Mac, NTFS) to non-case sensitive (eg. Fat32).