Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 12

I cannot get (publish?) my repository into GitHub

Solved! Go to Solution.

I have been programming for nearly half a century but I still am highly lost with Git and GitHub. The following is a log from Visual Studio Code.

 

Looking for git in: C:\Program Files\Git\bin\git.exe
Using git 2.17.1.windows.2 from C:\Program Files\Git\bin\git.exe
> git rev-parse --show-toplevel
> git config --get commit.template
Open repository: g:\Sam\Documents\Source\Repos
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
> git rev-parse --symbolic-full-name master@{u}
fatal: no upstream configured for branch 'master'
> git for-each-ref --format %(refname) %(objectname) --sort -committerdate
> git remote --verbose
> git check-ignore -z --stdin
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
> git rev-parse --symbolic-full-name master@{u}
fatal: no upstream configured for branch 'master'
> git for-each-ref --format %(refname) %(objectname) --sort -committerdate
> git remote --verbose
> git check-ignore -z --stdin
> git add -A -- .
> git commit --quiet --allow-empty-message --file - --all
> git config --get-all user.name
> git config --get-all user.email
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
> git rev-parse --symbolic-full-name master@{u}
fatal: no upstream configured for branch 'master'
> git for-each-ref --format %(refname) %(objectname) --sort -committerdate
> git remote --verbose

Probably the problem is that I had a phantom repository within my main repository so I deleted it (using Visual Studio I am nearly certain, not the file system) and separately deleted it using GitHub online.

 

So let me back up to the beginning. I have been trying to use Visual Studio (not VS Code) to get a Web App project uploaded (published?) into GitHub. I usually must stumble around but I eventualy get it to work. This time I could not. So I tried GitHub Desktop but I could not get it to work either, it just gives generic errors too. So I tried VS Code and that is what the log is from. I searched for:

 

"fatal: no upstream configured for branch" 'master'

And found another question that the answer probably does not apply here.

 

I found the following in StackOverflow:

 

  1. Visual Studio Git Not Updating and Commit Issues
  2. git - I cannot publish my VS Code repository to GitHUB

 

If either of those applies to my situation then I apologize for not knowing enough to understand them.

 

It is very frustrating for me that develpers of GUI interfaces to GitHub are unable to create an interface that is independent of the command-line commands and procedures. When I finally understand Git well enough I will create a GUI the way it should be done. At the moment I just want to uplaod some sample code for a totally different question.

11 Replies
Commander Lvl 3
Message 2 of 12

Re: I cannot get (publish?) my repository into GitHub

Hi @SimpleSamples ,

 

No problem if you don't understand it - we are here to help.

 

What exactly are you trying to achieve? If you'd just like to push (that is, I think, the most correct term to use) your local master branch to the master branch on GitHub you could use the following command:

git push --set-upstream origin master

If the GH remote is called origin (which it by default is), this will push your local master to the master on GitHub. You do need to execute this command manually, but after that automatically pushing using VS or VS Code should work fine without any manual actions from your side.

 

Let us know if you get more errors or need additional assistance!


- Mark
Copilot Lvl 3
Message 3 of 12

Re: I cannot get (publish?) my repository into GitHub

Thank you, Mark.

 

When I use a command prompt and go to the repository's path and issue that command I get:

 

fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

So I am not sure what is happening. Since I am not experienced with the use of the command line, I am not sure where the credentials are coming from. I tried to figure that out and just doing that makes my head spin; there are so many ways to specify credentials. Well I think that since I use Visual Studio I should assume I am using whatever it uses. Anyway, to attempt to learn things I tried the following.

 

G:\Sam\Documents\Source\Repos>git config -l --global
user.name=Sam Hobbs
user.email=SimpleSamples@users.noreply.github.com
gui.recentrepo=C:/Users/Sam/source/repos
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=manager

And that is very interesting. The most interesting part is the recentrepo. Windows allows us to specify a different partition for our "Documents" folder but it does not support it very well. Ugh! The relevant repository is in my G: (as shown in the preceding) but the preceding says C: for the recentrepo. So that is a likely problem. Right? Does that provide enough for you to suggest what to try next?

Commander Lvl 3
Message 4 of 12

Re: I cannot get (publish?) my repository into GitHub

Hi @SimpleSamples ,

 

Can you post the output of git remote -v when inside the repository here? Thanks!

 

Please check the output for sensitive information, and if so, censor it!


- Mark
Copilot Lvl 3
Message 5 of 12

Re: I cannot get (publish?) my repository into GitHub

I get nothing. I tried using both Git Bash and a Windows command prompt. Both produced no output, not even an error message.

 

I did that in the folder that has a .git directory; it has about eight projects in it.

 

So just to see if I could get that to work I went to my local repository for First Heroku Site. There is not much there but the output of the specified command is:

 

origin  https://github.com/SamHobbsOrg/HerokuFirst.git (fetch)
origin  https://github.com/SamHobbsOrg/HerokuFirst.git (push)

 

Commander Lvl 3
Message 6 of 12

Re: I cannot get (publish?) my repository into GitHub

@SimpleSamples  it is correct if Git then returns an empty response - it simply means you don’t have any remotes 

 

You simply need to add your own Git repository as a remote (using this article: https://help.github.com/en/articles/adding-a-remote) and then you can retry the command mentioned earlier.


- Mark
Copilot Lvl 3
Message 7 of 12

Re: I cannot get (publish?) my repository into GitHub

Thank you @mpboom. I think I am making progress. After adding the remote I tried the push again and I get:

 

G:\Sam\Documents\Source\Repos>git push --set-upstream origin master
git: 'credential---help' is not a git command. See 'git --help'.
To https://github.com/SimpleSamples/Repos.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/SimpleSamples/Repos.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.

I think the part about credential---help is my mistake resulting from my attempt to figure things out. I hope it is doing nothing except produce that warning. As ar as you do not have locally that gets back to my original post, I did delete a project that I know I should not have. I deleted it both in my local and remote repositories but I should have known that Git has data about things like that. So I need to clean up what is in the remote.

 

Would it work to just create a new remote? I have everything locally. Can I first rename the existing remote? Or I should delete the remote but if nothing else I do not mind using a different name.

Copilot Lvl 3
Message 8 of 12

Re: I cannot get (publish?) my repository into GitHub

I posted a reply but then I edited it a couple of times then it needed approval but I think now it is gone. I apologize if the following is a duplicate.

 

Thank you @mpboom. I think I am making progress. After adding the remote I tried the push again and I got:

 

G:\Sam\Documents\Source\Repos>git push --set-upstream origin master
git: 'credential---help' is not a git command. See 'git --help'.
To https://github.com/SimpleSamples/Repos.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/SimpleSamples/Repos.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.

I think the part about credential---help is my mistake resulting from my attempt to figure things out. I hope it is doing nothing except produce that warning. As far as you do not have locally that gets back to my original post, I did delete a project that I know I should not have. I deleted it both in my local and remote repositories but I should have known that Git has data about things like that. So I need to clean up what is in the remote.

 

Would it work to just create a new remote? I have everything locally. Can I first rename the existing remote? Or I can delete the remote but if nothing else I do not mind using a different name.

Solution
Commander Lvl 3
Message 9 of 12

Re: I cannot get (publish?) my repository into GitHub

@SimpleSamples you probably made some commits to the repository online that aren't on your computer yet. But that is no problem! Git is designed exactly for this.

 

Do a git pull inside the repository and Git will "download" the commits you made online to your computer. If you have happend to have the same file on the GitHub site and locally, you might get a merge conflict. Even that is no big deal, just follow the instructions Git gives you and/or use this article: https://help.github.com/en/articles/about-merge-conflicts .

 

I think I am making progress.

You definitely are!

 

Would it work to just create a new remote? I have everything locally. Can I first rename the existing remote? Or I can delete the remote but if nothing else I do not mind using a different name.

No, changing the remotes won't fix it. It's just that you've made commits both locally and online. That leads to Git getting a bit out of sync - but remember: it was designed for this!


 


- Mark
Copilot Lvl 3
Message 10 of 12

Re: I cannot get (publish?) my repository into GitHub

Hopefully this is just a progress report. I am getting:

 

fatal: refusing to merge unrelated histories

If that is expected for the situation described previously then I should be able to proceed with the merge and such.