Search code examples
gitgithubgit-remote

How to remove the git remote origin and add new remote origin?


I have cloned the code from one git repo of another person and now I want to commit the code to my git repo. How I can do this without copy-pasting post-checkout separately?

Any git reference would be more helpful.


Solution

  • Run the below commands in sequence:

    • git remote

    Will get the current remote path

    • git remote remove <remote path>

    So now your remote link will be deleted, now you can add your repo and commit your changes, anyway confirm whether the remote has been deleted using below command

    • git remote

    Nothing should be displayed

    • git remote add origin <your git repo http path>

    Now your repo will be added as git repo to this folder, so now push your code changes to the new repo using below command.

    • git push origin master