Creating a Full Copy of a Git Repository

Guest post from Peter Van de Voorde on creating a full copy of a Git repository. Learn more with his step by step guide.

Creating a Full Copy of a Git Repository
Git Repo

A guest post by Peter Van de Voorde
I recently had to create a full copy of a GIT repository without the need for a link back to the old repository but with all branches, tags and the full history of the old repository.

And I wanted to share my way of doing this with anybody out there wanting to do the same.

Let’s call the original repository ORI and the new one NEW, here are the steps I took to copy everything from ORI to NEW:

Create a local repository using a git clone ORI in the directory
Go into the directory.
Do git branch -a ,you’ll now see a list of the different branches in ORI
Use git checkout –track origin/branch-name to checkout all the branches you want to copy from ORI to NEW.
don’t checkout branches with -> in them, they are not real branches.
Now fetch all the tags from ORI using git fetch –tags
You can check your local tags using the git tag command and your local branches using the git branch -a command, do this before executing the next step.
Now clear the link to the ORI repository with the following command: git remote rm origin .
Now link your local repository to your newly created NEW repository using the following command:
git remote add origin
Now push all your branches and tags with these commands:
git push origin –all to push your branches
git push –tags to push your tags
You now have a full copy from your ORI repo.

About Peter Van de Voorde

Peter is a 30-something Belgian with a passion about everything Agile. By day he’s an Atlassian Expert and ALM Consultant at RealDolmen. In the evening he’s a family man, an active member of Atlassian Answers and the Atlassian Belgian User Group, and a boardgame fanatic. To see Peter’s previous guest posts for Clearvision, see our guest posts tag. For more by Peter, visit his website: http://www.petervandevoorde.com/

Atlasssian expert resources

Visit our blog for expert news and articles from the Atlassian world. On our resources page you will find recorded webinars, white papers, podcasts, videos and more.

The Software Blog

Read our blog for articles offering best practice advice written by Atlassian experts, as well as the latest news concerning your software.

Software White Papers and Guides

Dive deep into Atlassian software with our white papers and guides on individual tools, partner products, services, and best practices, written by the experts.

Expert Webinars

All of our webinars are pre-recorded and available to watch on-demand. Enjoy everything from partner features to application demos and updates from Atlassian experts.

Subscribe to our Newsletter

Subscribe to our Newsletter