Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git has forgotten the remote repository I fetch from / push to

Tags:

git

repository

This morning I went to do a git fetch and got the following error:

fatal: No remote repository specified. Please, specify either a URL or a remote name from which new revisions should be fetched.

This used to work fine. It looks like git has forgotten the link between (all) my branches and the repository.
Typing git remote -v doesn't return anything.
It was working at the end of last week, and the only thing that I can think of that I have changed was installing the latest GitExtensions release. However right now I am more worried about whether there is some way I can get back the repository information.
Any ideas?

Update:
My .git/config file was empty. Although I don't know the cause, I was able to remote desktop to another computer in the company and retrieve the "remote" section of its config.
I have updated my config file, and so far it looks like it is working :-)

Update 2: I have also needed to relink the branches to the origin via:

git config branch.develop.remote origin
git config branch.develop.merge refs/heads/develop

etc

like image 848
hamishmcn Avatar asked Aug 01 '11 23:08

hamishmcn


3 Answers

  1. You can take a look on .git/config and configure it.

  2. You can also make your local branch track back your remote branch by typing

    git branch --set-upstream <localbranch> <remotebranch>

When you type git fetch the local branch will fetch codes from those tracking remote branch.

like image 145
TheOneTeam Avatar answered Oct 19 '22 23:10

TheOneTeam


Seems like a very old question, but want to update to Kit Ho's answer with slight modification. Might be useful for someone.

git branch --set-upstream <localbranch> <remotebranch> 

is deprecated as of git version 1.9.2. This is the correct syntax now,

git branch --set-upstream-to=<upstream>

An example would be,

git branch --set-upstream-to=originremote/testbranch
like image 23
drrd Avatar answered Oct 19 '22 22:10

drrd


Remote information should be stored in the .git/config file, check that file and see if it's corrupted. If it is you might have to re-add every remote you had before or do a clean checkout, if it is there, there might be a bug in the GitExtension release...

like image 4
Charles Ma Avatar answered Oct 19 '22 22:10

Charles Ma