Andre Schütz - Learn. Think. Reflect - Tech developer
Git: Clone repo and create new origin and upstream

Git: Clone repo and create new origin and upstream

The task is to clone a repository and set a new origin. Additionally, the original origin becomes a new upstream.

Step 1: Clone the original repository

git clone original-remote-git-repository

Step 2: Remove the original remote origin from the repo

cd original-remote-git-repository
git remote rm origin

Step 3: Add the original remote url as new upstream path

git remote add upstream original-remote-git-repository

Step 4: Fetch the upstream

git fetch upstream
git merge upstream

Step 5: Add the new origin

git remote add origin my-new-remote-origin-repository

Step 6: Push to the new origin

git push -u origin master