Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Thursday, October 23, 2014

Retro Forking with Git and GitHub

Problem: You cloned a repository that you don't have write access to and you've done some work on it. Now you want to commit that work and push it to GitHub but you never did a fork.

1. Fork the repository, for my example I'm using https://github.com/rjrodger/seneca-mvp

2. In the console in the local repository folder do "git remote -v" to find out what the remote address is:

$ git remote -v
origin    git@github.com:rjrodger/seneca-mvp.git (fetch)
origin    git@github.com:rjrodger/seneca-mvp.git (push)

3. Add this repository as the upstream repository with "git remote add":

git remote add upstream https://github.com/rjrodger/seneca-mvp

4. "git remote -v" should now show:

$ git remote -v
origin    git@github.com:rjrodger/seneca-mvp.git (fetch)
origin    git@github.com:rjrodger/seneca-mvp.git (push)
upstream    https://github.com/rjrodger/seneca-mvp (fetch)
upstream    https://github.com/rjrodger/seneca-mvp (push)


5. Change the origin to your fork:

git remote set-url origin git@github.com:guyellis/seneca-mvp.git

6. Confirm the change:

$ git remote -v
origin    git@github.com:guyellis/seneca-mvp.git (fetch)
origin    git@github.com:guyellis/seneca-mvp.git (push)
upstream    https://github.com/rjrodger/seneca-mvp (fetch)
upstream    https://github.com/rjrodger/seneca-mvp (push)

Friday, December 6, 2013

Useful Git and GitHub Commands

My notebook for Git/GitHub commands that I find useful.

To change where your local repo thinks it originally cloned itself from drop onto a command line in the appropriate directory and:
> git remote set-url origin https://github.com/<new location>
This is useful when working with a forked repo that you want to keep up-to-date with the original repo while you're working on the fork. Allows you to flip between both of them and keep changes from both current.
Follow the above command with a 
> git pull
to update from the <new location>