How to remove upstream remote repository in Github


When you forking repository, you usually add stream to enable push your changes into origin master. Adding stream to remote repository by :

1
git remote add upstream git://github.com/octocat/Spoon-Knife.git

But how to remove upstream if we use wrong github repository. Adding again will throw error “fatal: remote upstream already exists”, for example like this:

1
fatal: ‘git//github.com/narfdotpl/jquery-typing.git’ does not appear to be a git repository

To solve this problem, edit .git/config and remove upstream :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = git@github.com:yodiaditya/jquery-typing.git
[branch "master"]
        remote = origin
        merge = refs/heads/master
[remote "upstream"]
        url = git://github.com/narfdotpl/jquery-typing.git
        fetch = +refs/heads/*:refs/remotes/upstream/*

Into

1
2
3
4
5
6
7
8
9
10
11
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = git@github.com:yodiaditya/jquery-typing.git
[branch "master"]
        remote = origin
        merge = refs/heads/master

Then you can add new upstream git agains. 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.