Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git removing upstream from local repository

I am working with a ruby on rails application and I am trying to sync a fork. It is worth mentioning that I am also on a Mac. I committed the following action:

$ git remote -v 

to get a view of my local repository. I messed up when trying to go upstream:

$ git remote add upstream https://github.com/foo/repo.git 

When I should have capitalized Foo:

$ git remote add upstream https://github.com/Foo/repos.git 

The question is how do I remove the upstream because every time I try and change this it comes back with creating a fatal error?

like image 667
user2603138 Avatar asked Nov 05 '13 23:11

user2603138


People also ask

What does unset upstream branch do?

If you like, you can use --unset-upstream to remove the upstream and stop the complaints, and not have local branch source marked as having any upstream at all. The point of having an upstream is to make various operations more convenient.

How do I reset my upstream branch?

You can reset your local master branch to the upstream version and push it to your origin repository. (You can define the original repo as "upstream" with git remote add upstream /url/to/original/repo .) It should probably be git reset --hard upstream/master to reset the working directory, too.


1 Answers

Using git version 1.7.9.5 there is no "remove" command for remote. Use "rm" instead.

$ git remote rm upstream $ git remote add upstream https://github.com/Foo/repos.git 

or, as noted in the previous answer, set-url works.

I don't know when the command changed, but Ubuntu 12.04 shipped with 1.7.9.5.

edit: a few people seem to have run into a situation where they do not have an "upstream" remote. execute cat .git/config and look at the name of the remote(s). (if on windows and not using powershell you can use type .git/config.)

the output will show the remotes configured for your git repo, e.g.,

[remote "origin"] 

substitute the name of the remote you wish to remove as:

$ git remote rm origin 

if you don't have the "upstream" remote, you can't remove it.

like image 115
bmacnaughton Avatar answered Sep 18 '22 14:09

bmacnaughton