---
title: "Copying your code to a new Git repository"
date: "2024-02-14T06:18:38+00:00"
summary: "Learn how to seamlessly transfer your code to a new Git repository while preserving your existing codebase. Follow our step-by-step guide for a smooth transition and maintain your development workflow."
image:
type: "page"
url: "/acquia-cloud-platform/copying-your-code-new-git-repository"
id: "6a21c673-a5bd-4b9b-a4a7-992911e70dd2"
---

Occasionally you may need to remove and replace your current code repository, while keeping the existing code intact.

To copy your code from an existing Cloud Platform repository to a new repository:

1.  [Clone the code from the existing repository](/acquia-cloud-platform/develop-apps/repository/checkout) to ensure you have a recent, accurate version of your codebase.
2.  Open a command prompt window, and then run the following command to ensure you have the most up to date code commits:
    
        git log
    
3.  Use the following command to add the new code repository as a remote, which will enable you to push code to the new repository using the same method as the origin:
    
        git remote add new-origin
    
4.  Validate that the new remote origin has been added properly by using the following command:
    
        git remote -v
    
5.  Push the mirrored code to the new origin:
    
        git push --mirror new-origin
        git push --all new-origin
        git push --tags new-origin
    
6.  With the following commands, rename the origin to be the new repository:
    
        git remote rename origin old-origin
        git remote rename new-origin origin
    

Your code repository should now have a clean, working copy of the previous code.