0

I'm perplexed at how little I know about git, so I'm trying to create a project on GitHub to get some practice.

I've created an empty repository on the website, following this official guide

Then, as suggested:

echo "# test" >> README.md
git init
git add README.md
git commit -m "first commit"

I also configured a mail and name for this repository and continued the guide:

git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git remote add origin https://github.com/saatomic/test.git
git push -u origin master

It doesn't seem to matter what I try, I always get the following when I try to push the local data:

error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/saatomic/test.git'

I'm quite lost - as I've strictly followed the propsed guide by GitHub.

What am I doing wrong and how do I correctly push my local data?

edit:

$ git remote -v
origin  https://github.com/saatomic/test.git (fetch)
origin  https://github.com/saatomic/test.git (push)

Update: I was able to do exactly the same on a different Linux VM, where everything succeeded as intended. This appears to be an issue of my local system. I can't grasp why (Updated Ubuntu 17.04), git version 2.11.0.

Update #2: I've retried the very same on an Ubuntu 16.04.3 LTS, git version 2.7.4, the same issue.

Update 3: Not a duplicate of this question. I've tried all the suggestions there, I should have mentioned that.

I've tried to add, commit and change branches, as suggested. The pushes still fail with the same error message.

error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/saatomic/test.git'

Also suggested (both report nothing at all):

$ git show-ref
$
$ git branch
$ 

Force pushes don't work either and I do have a pending commit:

$ git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

    new file:   README.md

Solved: The issue was, that I had to configure the mail and username and then make a new commit.

git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git commit -m "post-conf commit"
SaAtomic
  • 619
  • 1
  • 12
  • 29
  • Could you post your output from `git remote -v`? – Víctor López Sep 26 '17 at 10:57
  • @VíctorLópez I've edited the question and added the output – SaAtomic Sep 26 '17 at 11:00
  • It seems all it's ok... If you run `git branch`, you're on master? – Víctor López Sep 26 '17 at 11:03
  • Then, you can check if your commit was commited, running `git log`. If not, follow the steps you told us (`git add .` and then `git commit -m 'message'`). – Víctor López Sep 26 '17 at 11:04
  • `git branch` returns nothing and `git log` states `fatal: your current branch 'master' does not have any commits yet`. – SaAtomic Sep 26 '17 at 11:08
  • Well, it's all we need. For some reason, your commit fails. `git status` will tell you if your file is tracked or not, and you could commit if it is. If not, use vim, nano or some editor to create a file in your git repository and the commit it. I think it will solve your problem :) – Víctor López Sep 26 '17 at 11:10
  • Very weird. `git status` states that I'm on branch master and that I have a commit "Initial commit" with the following changes to be commited: `new file: README.md` – SaAtomic Sep 26 '17 at 11:12
  • Try using `git push origin master:master` – Claudio Sep 26 '17 at 11:48
  • @Claudio That results in the same error as shown in the question with `src refspec master does not match any.`. – SaAtomic Sep 26 '17 at 14:02
  • @SaAtomic Can you provide the output of `show-ref`: `git show-ref` – nitishagar Sep 27 '17 at 05:43
  • @nash_ag I've just run the command and it reports nothing at all – SaAtomic Sep 27 '17 at 07:13
  • Possible duplicate of [src refspec master does not match any when pushing commits in git](https://stackoverflow.com/questions/4181861/src-refspec-master-does-not-match-any-when-pushing-commits-in-git) – phd Sep 27 '17 at 08:05

1 Answers1

0

The issue was, that I had to configure the mail and username and then make a new commit.

git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git commit -m "post-conf commit"
SaAtomic
  • 619
  • 1
  • 12
  • 29