Thursday, August 29, 2013

HOW TO: Switch a cloned Git repo to your fork

Here we go, yo, so what's the scenario?

You clone a Git repository from, say, GitHub, to dive into the source code.  Eventually, you decide you would like to make some changes and submit a pull request.  You need to switch your repo to point to your fork. Here's how.

List the current remote(s)

Here we see I cloned the Jenkins project, which was itself forked from Kohsuke's account.

$ git remote --verbose
origin https://github.com/jenkinsci/jenkins.git (fetch)
origin https://github.com/jenkinsci/jenkins.git (push)
upstream https://github.com/kohsuke/hudson.git (fetch)
upstream https://github.com/kohsuke/hudson.git (push)

Replace the existing origin with your fork


$ git remote rm origin
$ git remote add origin https://github.com/olivierdagenais/jenkins.git

Replace the existing upstream with the old origin

...if applicable, of course.

$ git remote rm upstream
$ git remote add upstream https://github.com/jenkinsci/jenkins.git

Double-check the remote(s)


$ git remote --verbose
origin https://github.com/olivierdagenais/jenkins.git (fetch)
origin https://github.com/olivierdagenais/jenkins.git (push)
upstream https://github.com/jenkinsci/jenkins.git (fetch)
upstream https://github.com/jenkinsci/jenkins.git (push)

1 comment:

jane holly said...

This professional hacker is absolutely reliable and I strongly recommend him for any type of hack you require. I know this because I have hired him severally for various hacks and he has never disappointed me nor any of my friends who have hired him too, he can help you with any of the following hacks:

-Phone hacks (remotely)
-Credit repair
-Bitcoin recovery (any cryptocurrency)
-Make money from home (USA only)
-Social media hacks
-Website hacks
-Erase criminal records (USA & Canada only)
-Grade change
-funds recovery

Email: onlineghosthacker247@ gmail .com