Change remote 'origin' to 'upstream' with Git

Viewed 2032

I've cloned a Git repo from the original source's upstream master repo to my local machine.
git remote -v returns:

origin  https://github.com/project.git (fetch)
origin  https://github.com/project.git  (push)

But I now know that I need to instead fork this upstream master branch to my personal GitHub account, clone that, create a new branch, and begin coding (so that I'm not making changes directly to the upstream repo, but rather to my own forked origin repo). I've forked the upstream master to my GitHub profile, but don't know how to proceed. I need to get git remote -v to look like this:

origin    https://github.com/myGitHubProfile/project.git (fetch)
origin    https://github.com/myGitHubProfile/project.git (push)
upstream    https://github.com/project.git (fetch)
upstream    https://github.com/project.git  (push)

How can I accomplish this, given that I've already cloned the upstream master from the original source and it's already set as origin?

1 Answers

It seems like you're looking for:

git remote rename origin upstream
git remote add origin https://github.com/myGitHubProfile/project.git

To give "old" origin remote a new upstream name and add new remote named origin.

Related