0

So I open up my rails project in terminal today and make a few changes and try to push to github, and it doesn't work. I search on Google and stack overflow and all everyone points to the instructions on installing github to fix my issue.

So I went through all the instructions and I still get the same issue. PLEASE HELP!

admin@new-host-2:~/Desktop/sample_app$ git status
# On branch filling-in-layout
# Your branch is ahead of 'origin/filling-in-layout' by 3 commits.
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   app/views/pages/home.html.erb
#
no changes added to commit (use "git add" and/or "git commit -a")

admin@new-host-2:~/Desktop/sample_app$ git add .
admin@new-host-2:~/Desktop/sample_app$ git commit -am 'testing git yet again'
[filling-in-layout b607a16] testing git yet again
 1 files changed, 1 insertions(+), 1 deletions(-)
admin@new-host-2:~/Desktop/sample_app$ git push
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

admin@new-host-2:~/Desktop/sample_app$ ssh-add -l
The agent has no identities.

admin@new-host-2:~/Desktop/sample_app$ git credential-osxkeychain
Usage: git credential-osxkeychain <get|store|erase>

Also why does it say # Your branch is ahead of 'origin/filling-in-layout' by 3 commits?

Pavan Katepalli
  • 2,372
  • 4
  • 29
  • 52

1 Answers1

3

I'd suggest that this shows the reason

admin@new-host-2:~/Desktop/sample_app$ ssh-add -l
The agent has no identities.

You need to add your key to ssh-agent using ssh-add /path to keyfile

You'll be asked to enter your passphrase if you have one and then the key will be added to your keychain. You should then be able to push the commits up.

The reason it says "# Your branch is ahead of 'origin/filling-in-layout' by 3 commits" is because you haven't pushed your commits yet. Your local version is 3 commits ahead of the remote version. One you complete the push successfully this won't be the case.

Nick Perkins
  • 1,327
  • 2
  • 12
  • 25
  • Thank you Nick! How do I execute this part of your advice? "ssh-add /path to keyfile" – Pavan Katepalli Dec 28 '12 at 04:43
  • @PavanKatepalli have you pushed stuff up to github before? If so, you should have set up a ssh key which you use. Mine, for example, is located in the file '.ssh/github'. So at the command line I type `ssh-add ~/.ssh/github/`. If you haven't done this already you will need to - [this article](https://help.github.com/articles/generating-ssh-keys) should help – Nick Perkins Dec 28 '12 at 04:48
  • hey Nick I have before and I have a ssh key. I copied what you wrote into command line and it gave me a "No suh file or directory" – Pavan Katepalli Dec 28 '12 at 04:56
  • Your key may be in a different location. You'll need to find where you saved it. – Nick Perkins Dec 28 '12 at 04:58
  • got you. I did "cd ~/.ssh". then "ls". I got: "github_rsa github_rsa.pub known_hosts" – Pavan Katepalli Dec 28 '12 at 05:03
  • I don't know if I should delete everything and start over like the tutorial says, because I already have a ssh key with github – Pavan Katepalli Dec 28 '12 at 05:14
  • @PavanKatepalli Thanks. It's probably the github_rsa file. Give that a go. If you can't remember the passphrase you can always just create a new set of keys and update github. – Nick Perkins Dec 28 '12 at 05:18