tags:

views:

451

answers:

4

I am new to git and recently set up a new account with github. I'm following a rails tutorial from Michael Hartl online ( http://www.railstutorial.org/book#fig:github_first_page ) and followed his instructions to set up my git which were also inline with the setup instructions at github. Anyways, the "Next Steps" section on github were:

  mkdir sample_app
  cd sample_app
  git init
  touch README
  git add README
  git commit -m 'first commit'
  git remote add origin [email protected]:rosdabos55/sample_app.git
  git push origin master

I got all the way to the last instruction (git push origin master) without any problem. When I entered that last line into my terminal, however, I got this error message: "fatal: No path specified. See 'man git-pull' for valid url syntax." What might I be doing wrong?

Here are the contents of .git/config (reconstructed by Jefromi from the output of git config -l pasted into a comment below):

[user]
    name = Ross
    email = [email protected]
[core]
    editor = gvim -f
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = [email protected]:
    fetch = +refs/heads/*:refs/remotes/origin/*
A: 

Can you post the output of git remote show?

It looks like something went wrong when you added your remote repository (git remote add origin [email protected]:rosdabos55/sample_app.git).

Benjamin Manns
If I type in git remote show, the output is origin
@user306472 (OP): How about the output of `git remote show -n origin`?
Chris Johnsen
* remote origin URL: [email protected]: HEAD branch: (not queried) Local ref configured for 'git push' (status not queried): (matching) pushes to (matching)
That remote URL appears to be missing the path to the repository - it's just got the user and host. Try re-adding the remote with the URL in quotes (although I've never seen a shell that requires you to quote a colon...).
Jefromi
can you post the contents of .git/config? (it's easier on the eyes to edit the question and add it there)
zetetic
@ Jefromi: It still replies 'remote origin already exists'@zetetic: If I type in git config -l, the out put is '[email protected]=gvim -fcore.repositoryformatversion=0core.filemode=truecore.bare=falsecore.logallrefupdates=trueremote.origin.url=git@github.com:remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*'
@user306472: When I say re-add, I mean remove it and add it. Of course the remote exists. The problem is that it's been incorrectly configured. You can clearly see that in the config output you pasted - it says `[email protected]:`, completely missing the path that should've come after that. Clearly you didn't actually add the remote with that full URL. (If you like you can directly edit .git/config instead of `git remote rm origin; git remote add origin ...`)
Jefromi
@ Jefromi: I removed origin and then re-added w the URL in quotes and then tried git push origin master and everything worked out perfectly. Problem solved! I'm not sure why I had to put it in quotes, but I really appreciate your help.
@user306472: I've posted that as an actual answer, with a suggestion as to what you may've done wrong.
Jefromi
A: 

Try "git branch -r" to see whether you get the origin/master or not?

sza
Clearly not - the remote entry was added, and the only interaction over the network failed.
Jefromi
A: 

You may need to git pull origin before you git push origin master.

Tim Snowhite
I get the same error message either way
If you are pushing a new branch to a repository or pushing to a new repository you do not need to pull first.
Jamey Hicks
+5  A: 

I've stated this in the comments to another answer, but it's really the answer (and I've edited the appropriate section of the comments into the question where it belongs).

The URL for the remote was not configured correctly, for whatever reason. It's set to "[email protected]:", which is clearly missing the path, producing precisely the error you see. You need to reconfigure it correctly. You could simply edit .git/config, changing the appropriate line to contain the path. Or you could do this:

git remote rm origin
git remote add origin '[email protected]:rosdabos55/sample_app.git'

You almost certainly made some small typo or careless mistake when you added the remote the first time - perhaps you hit enter in the middle of it, perhaps you typed a space after the colon. (For some reason, git does not appear to throw an error when you provide an extra argument after remote add <name> <url> - it just ignores it.) The upshot is that you didn't actually run that command, and you added a remote with an incomplete URL.

Jefromi