Cloning a repository without making it the origin remote

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).

Leave a Comment