Matrix

Initialize and Push a Cloned Repository to a New Repository

13th June 2024
FullStack
FullStack
Git
Notes
Last updated:15th July 2024
1 Minutes
101 Words

When you clone a repository from another source and want to set it up and push it to your new personal repository, follow these steps:

  1. Clone the existing repository:
Terminal window
1
git clone <existing_repository_url>
2
cd <repository_name>
  1. Remove the old remote URL:
Terminal window
1
git remote remove origin
  1. Add your new remote URL:
Terminal window
1
git remote add origin <your_new_repository_url>
  1. Verify the remote URL is set correctly:
Terminal window
1
git remote -v
  1. Initialize the local repository (if not already initialized):
Terminal window
1
git init
  1. Add all changes and commit:
Terminal window
1
git add .
2
git commit -m "Initial commit"
  1. Push to the new remote repository:
Terminal window
1
git push -u origin main

If your default branch is not main but master or another name, replace main with the appropriate branch name.

Article title:Initialize and Push a Cloned Repository to a New Repository
Article author:Matrix Chan
Release time:13th June 2024