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.

Upvotes: 6

Views: 16759

Answers (2)

Gayathri Raghuram
Gayathri Raghuram

Reputation: 21

I would do a git remote -v , instead of git remote just to make sure that the full origin url(path) is right

Upvotes: 1

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

Upvotes: 19

Related Questions