1

I encountered this error when doing a git push:

fatal: could not read Username for 'https://usts.visualstudio.com': No such file or directory

Looks like I have hit a bug in git 1.8.5 as mentioned here: https://stackoverflow.com/a/20884273/45603

Google led me to this post: https://stackoverflow.com/a/20871910/45603

So, I ran git remote rm origin followed by git remote add origin 'git@github.com:username/repo.git'

Now I get the following message whenever I do a git push:

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

I would like to undo the git remote rm origin and rollback to git 1.8.4.

How do I undo git remote rm origin?

Edit: Running git push --set-upstream origin master (as advised by git) gives me the following error:

ssh: connect to host usts.visualstudio.com port 22: Bad file number
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Community
  • 1
  • 1
Agnel Kurian
  • 57,975
  • 43
  • 146
  • 217
  • possible duplicate of [Git SSH error: "Connect to host: Bad file number"](http://stackoverflow.com/questions/7144811/git-ssh-error-connect-to-host-bad-file-number) – Aaron Digulla Feb 10 '14 at 10:02

3 Answers3

1

You can't "undo" a git remote rm call.

Besides, you don't need to undo the git rm. Just run the command as indicated.

Or just run git push origin master (or whatever branch you're on).

rossipedia
  • 56,800
  • 10
  • 90
  • 93
1

git remote rm origin removes the connection to the remote server. git remote add origin <user>@<url> will recreate this connection. It looks as though when you ran git remote add origin <user>@<url> you entered the wrong url or the wrong username. Maybe just a typo.

To check, run git remote -v. This will display the connection string for the remote repository that is currently configured. Check it against the documentation provided by Visual Studio Online. If it is wrong, just do git remote rm origin again and then git remote add origin <user>@<url> again with the correct details.

If you are unsure what I mean or you have tried this and it doesn't work, then please post the exact commands you are using and the exact output of git remote -v, and I will see if I can find the error.

naomi
  • 1,934
  • 1
  • 14
  • 29
  • Hi, sorry I didn't see this 2 days ago. You could post the command but with your username changed? – naomi Feb 10 '14 at 09:19
0

To fix this issue, you need to tell git that your local master branch tracks the remote branch, which is what the error is telling you to do. By running git push --set-upstream origin master, you are telling git that the current branch tracks origin/master

Dan McClain
  • 11,780
  • 9
  • 47
  • 67