RE: fatal: The current branch master has no upstream branch. | and also 'https://gitbuh.com/MyName'

Hello, I joined Github last week, created and initiated my first two repositories. Now I want to add, commit and push revised files to those repositories. When I pushed the revised files, I received the following response: ----------------------------------------- $ 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 ------------------------------------------ So I did, and received response: My Name@DESKTOP-32QET7M TINGS64 ~/Desktop (master) — (I revised this line, with same type of characters) $ git push --set-upstream origin master fatal: unable to access ‘https://gitbuh.com/AnneMarieHarm/deliverable_one.git/’: Could not resolve host: gitbuh.com ------------------------------------ I wonder how it became ‘gitbuh.com’ (not ‘github.com’)? And why I can’t seem to push revised files to my respositories? Any help anyone may be able to provide, would be appreciated. I’ve reviewed help files and references, and found this other user receiving some of the same responses (https://github.community/t5/How-to-use-Git-and-GitHub/Pushing-to-collaborator-s-private-repo-from-terminal/m-p/4170 VishAlSahim Ground Controller Lvl 1 ‎02-23-2018 07:55 PM Message 1 of 2 Pushing to collaborator’s private repo from terminal: ) ------------------------------------------- However VishAlSahim’s situation seems more complex, as he is trying to collaborate by using or contributing to someone else’s repository. Thank you!

1 Like

Hi @annemarieharm, you can ammend your remote URL with the following command:

git remote set-url origin https://github.com/AnneMarieHarm/deliverable_one.git
15 Likes

Hi strafe, 

I appreciate the reply; that is the same thing Stacey from Github Support recommended I do, with the addition of ‘.git’ at the end (in your case). I also see this referenced in the article she referred me to (https://help.github.com/articles/changing-a-remote-s-url/) – complete with .git at the end. However, this has not worked in my case; I’ve pasted recent results of that effort, below my signature. Any other options come to mind?

Thank you. ~ Anne Marie

Anne Marie Harm@DESKTOP-32QE01T MINGW64 ~/Desktop (master)
$ git remote set-url origin https://github.com/AnneMarieHarm/deliverable_one.git

Anne Marie Harm@DESKTOP-32QE01T MINGW64 ~/Desktop (master)
$ 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

Anne Marie Harm@DESKTOP-32QE01T MINGW64 ~/Desktop (master)
$ git push --set-upstream origin master
git remote set-To https://github.com/AnneMarieHarm/deliverable_one.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘https://github.com/AnneMarieHarm/deliverable _one.git’
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.

Hi @annemarieharm, I’m glad your first issue is resolved. You can see the hints tell you there’s commits on the remote that you don’t have locally, this means it’s preventing you form pushing so you don’t erase those commits from the remote. Assuming there aren’t going to be any conflicts you should be able to use:

git pull origin master

followed by:

git push
2 Likes

Hi strafe,
Again I appreciate your response. I tried that, and received the following:

Anne Marie Harm@DESKTOP-32QE01T MINGW64 ~/Desktop (master)
$ git pull origin master
From https://github.com/AnneMarieHarm/deliverable_one
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories

Anne Marie Harm@DESKTOP-32QE01T MINGW64 ~/Desktop (master)
$ 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 think next I’ll read up on doing a git pull, in case I haven’t done that correctly – and see what I find out. I do see that I may not have been in a good position to proceed to git push, from this message:

From https://github.com/AnneMarieHarm/deliverable_one
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories

Thank you for your help. ~ Anne Marie

1 Like

Hi Strafe,

I am grateful for your responses; it now looks like the git remote set-url origin https://github.com/AnneMarieHarm/deliverable_one (with or without the .git file extension) resolved one of my issues (‘gitbuh.com’ typo). But it turns out while_ git pull_ may well also have allowed me to revise the files in question, I suspect it may have created others (and there was a simpler solution). Please let me know if you (or anyone else) would like further information.

Either way I hope to remember these lessons, and all I learned by A) hearing back from you (and Stacey from Github Support), and B) reviewing and studying related documentation – how the issues I experienced compelled me to become more familiar. And how nice it was, when it finally worked!

Thank you. ~ Anne Marie

Hi Anne Marie, I have the same problem and could not solve it!!

Thanks for your answer!!

1 Like

Hai Anne Marie. Currently I am facing the same problem with what you had. I could not push or pull and had the same messages. I was wondering if you could share the full solution? 

Thank you. 

The problem is that you have to update your credential. When done updating your credential, use git push --set-upstream origin master for the first time after that you can use git push

https://help.github.com/en/github/using-git/updating-credentials-from-the-osx-keychain

2 Likes

I appreciate the response, and love the fact that I’m receiving it almost a year and a half after posting my question. It testifies to a great reality of online user forums, and the way shared knowledge and experience accrue. Thank you!

1 Like

You’re gonna hate me, but I solved it in a very ugly way. First, my context:

  1. I just finished moving a local repository to github by following this
  2. To check whether this did the trick, I open my browser to my github repository and locally make a small edit to README.md
  3. I type
    git add README.md
    git commit -m . 
    git push
  4. I get the error
    fatal: The current branch master has no upstream branch.

Solution: I edited .git/config and added the last three lines:

[core]
	repositoryformatversion = 0
	filemode = false
	bare = false
	logallrefupdates = true
	symlinks = false
	ignorecase = true
[remote "origin"]
	url = https://github.com/benreaves/whatever.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master

It’s working for me. If any of you want to yell at me, please go ahead, but from a safe social distance of 2 meters :slight_smile:

1 Like

I realize it’s a figure of speech, but I’ll never hate you. Glad you’re out there, doing what you do! Thank you.

https://blog.google/technology/safety-security/expediting-changes-google-plus/

1 Like

Thx it seems it helped!

1 Like

Had the same problem.
git branch --set-upstream-to origin/master or
git branch -u origin/master
adds those 3 lines to .git/config, per

Try this command works really well:
git push origin master -f

1 Like

yup it’s works for me too.