I am new to Git/GitHub and am having enormous difficulty pushing my new repo up to GitHub.
I created my project locally, which essentially has the following directory structure:
myapp/
src/
<A bunch of source files>
build.grade
gradle.properties
README.md
.gitignore
For good measure, here's my .gitignore
(in case its the culprit):
.idea
*.iml
*.ipr
*.iws
/out
.gradle
/build
/files
/*.yaml
/*.sh
I confirmed Git was installed by running git —version
which produces:
git version 2.3.2 (Apple Git-55)
I then created a new GitHub repo (private) and left it empty so I wouldn’t have to merge anything.
I then attempted to init my project as a new git repo and here’s the command-line history:
myuser@mac:~/sandbox/eclipse/workspace/myapp$ git init
Initialized empty Git repository in /Users/myuser/sandbox/eclipse/workspace/myapp/.git/
myuser@mac:~/sandbox/eclipse/workspace/myapp$ git commit -am "Initial barebones commit."
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'myuser@mac.(none)')
myuser@mac:~/sandbox/eclipse/workspace/myapp$ git config --global user.email "myuser@example.org”
myuser@mac:~/sandbox/eclipse/workspace/myapp$ git config --global user.name “mygithubusername”
myuser@mac:~/sandbox/eclipse/workspace/myapp$ git commit -am "Initial barebones commit."
On branch master
Initial commit
Untracked files:
.classpath
.gitignore
.project
.settings/
README.md
bin/
build.gradle
gradle.properties
gradle/
gradlew
gradlew.bat
src/
nothing added to commit but untracked files present
myuser@mac:~/sandbox/eclipse/workspace/myapp$ git remote add origin https://github.com/mygithubusername/myapp.git
myuser@mac:~/sandbox/eclipse/workspace/myapp$ git push -u origin master
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/mygithbusername/myapp.git'
So as you can see I tried:
- Running
git init
- Adding and pushing changes to the local repo, but had to first setup my email and username (again I’m brand new to Git here)
- Added & committed
- Added the new remote repo
- Tried pushing to that remote rep
According to this answer, this “src ref spec master does not match any” error may be due to the fact that I have’t actually committed anything yet, which might jive with the “untracked file” errors/warnings I see above it.
Either way, where did I go awry, and what do I do to fix it?