116

Why am I getting this error when my Git repository URL is correct?

fatal: 'git@skarp.beanstalkapp.com/gittest.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

See it in context below, or as a screenshot.

jitendra@JITENDRA-PC /c/mySite (master)
$ git push beanstalk master
fatal: 'git@skarp.beanstalkapp.com/gittest.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

jitendra@JITENDRA-PC /c/mySite (master)
$ git clone git://github.com/jquery/jquery.git
Cloning into jquery...
Remote: Counting objects: 19803, done.
Remote: Compressing objects: 100% (5196/5196), done.
Remote: Total 19803 (delta 14204), reused 19549 (delta 14052)
Receiving objects: 100% (19803/19803), 12.80 MiB | 591 KiB/s, done.
Resolving deltas: 100% (14204/14204), done.

jitendra@JITENDRA-PC /c/mySite (master)
$ gitk --all

jitendra@JITENDRA-PC /c/mySite (master)
$ gitk -all

jitendra@JITENDRA-PC /c/mySite (master)
$ git remote add origin git@skarp.beanstalkapp.com/gittest.git

jitendra@JITENDRA-PC /c/mySite (master)
$ git push origin master
fatal: 'git@skarp.beanstalkapp.com/gittest.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

jitendra@JITENDRA-PC /c/mySite (master)
Michael
  • 8,362
  • 6
  • 61
  • 88
Jitendra Vyas
  • 148,487
  • 229
  • 573
  • 852
  • Are you sure it's ok? Can you clone from gettest.git? You're cloning another one jquery in the above example. – Preet Sangha Sep 06 '11 at 11:14
  • i want to add my local folder+files to my git hosting – Jitendra Vyas Sep 06 '11 at 11:28
  • 29
    for future reference, please include text in questions - as text. Image of text go offline, and even if they don't, they prevent copying and pasting etc. – AD7six Jan 24 '13 at 13:49
  • Related: [git 'origin' does not appear to be a git repository](http://stackoverflow.com/questions/15437719/git-origin-does-not-appear-to-be-a-git-repository). –  Jun 27 '14 at 13:23
  • i spent 20 minutes on this and it turned out i just typoed the repo name lol – don bright Apr 30 '23 at 20:15

10 Answers10

101

You've got the syntax for the scp-style way of specifying a repository slightly wrong - it has to be:

[user@]host.xz:path/to/repo.git/

... as you can see in the git clone documentation. You should use instead the URL:

git@skarp.beanstalkapp.com:/gittest.git

i.e. in the URL you're using, you missed out the : (colon)

To update the URL for origin you could do:

git remote set-url origin git@skarp.beanstalkapp.com:/gittest.git
Mark Longair
  • 446,582
  • 72
  • 411
  • 327
  • 3
    Thanks . but then why i didn't get any error when i added remote – Jitendra Vyas Sep 06 '11 at 11:34
  • Now I tried with `git@skarp.beanstalkapp.com:/gittest.git` but getting error `remote origin already exists` – Jitendra Vyas Sep 06 '11 at 11:37
  • 5
    You can first remove the origin remote with `git remote rm origin` and then add it again. Then on your first push, you may want to add the `-u` parameter (i.e. `git push -u origin master`) if you want `master` in that repository to be your default upstream for your `master`. – Mark Longair Sep 06 '11 at 11:39
  • removing and re-adding worked. without `-u`. thanks. I'm very new to version control using any version control first time. – Jitendra Vyas Sep 06 '11 at 11:45
  • 1
    You could also edit file ".git/config" and update url in [remote "origin"] – dxvargas Feb 17 '13 at 17:18
33

I met a similar problem when I tried to store my existing repo in my Ubunt One account, I fixed it by the following steps:

Step-1: create remote repo

$ cd ~/Ubuntu\ One/
$ mkdir <project-name>
$ cd <project-name>
$ mkdir .git
$ cd .git
$ git --bare init

Step-2: add the remote

$ git remote add origin /home/<linux-user-name>/Ubuntu\ One/<project-name>/.git

Step-3: push the exising git reop to the remote

$ git push -u origin --all
vHow
  • 711
  • 7
  • 6
21

This is typically because you have not set the origin alias on your Git repository.

Try

git remote add origin URL_TO_YOUR_REPO

This will add an alias in your .git/config file for the remote clone/push/pull site URL. This URL can be found on your repository Overview page.

rizon
  • 8,127
  • 1
  • 27
  • 17
7

my local and remote machines are both OS X. I was having trouble until I checked the file structure of the git repo that xCode Server provides me. Essentially everything is chmod 777 * in that repo so to setup a separate non xCode repo on the same machine in my remote account there I did this:

REMOTE MACHINE

  1. Login to your account
  2. Create a master dir for all projects 'mkdir git'
  3. chmod 775 git then cd into it
  4. make a project folder 'mkdir project1'
  5. chmod 777 project1 then cd into it
  6. run command 'git init' to make the repo
  7. this creates a .git dir. do command 'chmod 777 .git' then cd into it
  8. run command 'chmod 777 *' to make all files in .git 777 mod
  9. cd back out to myproject1 (cd ..)
  10. setup a test file in the new repo w/command 'touch test.php'
  11. add it to the repo staging area with command 'git add test.php'
  12. run command "git commit -m 'new file'" to add file to repo
  13. run command 'git status' and you should get "working dir clean" msg
  14. cd back to master dir with 'cd ..'
  15. in the master dir make a symlink 'ln -s project1 project1.git'
  16. run command 'pwd' to get full path
  17. in my case the full path was "/Users/myname/git/project1.git'
  18. write down the full path for later use in URL
  19. exit from the REMOTE MACHINE

LOCAL MACHINE

  1. create a project folder somewhere 'newproj1' with 'mkdir newproj1'
  2. cd into it
  3. run command 'git init'
  4. make an alias to the REMOTE MACHINE
  5. the alias command format is 'git remote add your_alias_here URL'
  6. make sure your URL is correct. This caused me headaches initially
  7. URL = 'ssh://user@www.somemachine.com/Users/myname/git/project1.git'
  8. after you do 'git remote add alias URL' do 'git remote -v'
  9. the command should respond with a fetch and push line
  10. run cmd 'git pull your_alias master' to get test.php from REMOTE repo
  11. after the command in #10 you should see a nice message.
  12. run command 'git push --set-upstream your_alias master'
  13. after command in 12 you should see nice message
  14. command in #12 sets up REMOTE as the project master (root)

For me, i learned getting a clean start with a git repo on a LOCAL and REMOTE requires all initial work in a shell first. Then, after the above i was able to easily setup the LOCAL and REMOTE git repos in my IDE and do all the basic git commands using the GUI of the IDE.

I had difficulty until I started at the remote first, then did the local, and until i opened up all the permissions on remote. In addition, having the exact full path in the URL to the symlink was critical to succeed.

Again, this all worked on OS X, local and remote machines.

James Danforth
  • 781
  • 7
  • 7
  • Thank you soo much for this! I was having issues with my directory permissions and it took me forever to find a post that actually listed them! – Mike Feb 08 '17 at 03:46
  • Point 7 for LOCAL MACHINE is also missing the colon... not very helpful :p – Carlo Wood Mar 31 '17 at 20:59
6

It is most likely that you got your repo's SSH URL wrong.

To confirm, go to your repository on Github and click the clone or download button. Then click the use SSH link.

ssh link

Now copy your official repo's SSH link. Mine looked like this - git@github.com:borenho/que-ay.git

You can now do git remote add origin git@github.com:borenho/que-ay.git if you didn't have origin yet.

If you had set origin before, change it by using git remote set-url origin git@github.com:borenho/que-ay.git

Now push with git push -u origin master

Kaka Ruto
  • 4,581
  • 1
  • 31
  • 39
3

I was facing same issue with my one of my feature branch. I tried above mentioned solution nothing worked. I resolved this issue by doing following things.

  • git pull origin feature-branch-name
  • git push
Himanshu Shekhar
  • 1,196
  • 1
  • 16
  • 35
1

I had a similar problem when using TFS 2017. I was not able to push or pull GIT repositories. Eventually I reinstalled TFS 2017, making sure that I installed TFS 2017 with an SSH Port different from 22 (in my case, I chose 8022). After that, push and pull became possible against TFS using SSH.

Wolfgang Grinfeld
  • 870
  • 10
  • 11
1

None of this worked for me. The problem appeared to be a lot more mundane...

I spent about a day figuring out the name of my Synology volume is not "Volume1" but "volume1".

I do not feel that stupid about it considering URLs are typically not case sensitive, Windows file paths are not case sensitive and last but not least: references to volume1 in the DSM user interface (e.g. Hyper Backup) are capitalized! (to make them look nice?). I finally found it poking around in SSH noticing that casing mattered when changing directories. And so it does when specifying the URL for the remote repository.

Martin Maat
  • 714
  • 4
  • 23
1

I got similar issue. In my case to solve was to unset the environment variable HOMEBREW_BREW_GIT_REMOTE.

unset HOMEBREW_BREW_GIT_REMOTE
broue
  • 11
  • 2
0

I have a similar problem, but now I know the reason.

After we use git init, we should add a remote repository using

git remote add name url

Pay attention to the word name, if we change it to origin, then this problem will not happen.

Of course, if we change it to py, then using git pull py branch and git push py branch every time you pull and push something will also be OK.

JChen___
  • 3,593
  • 2
  • 20
  • 12
  • 1
    Thanks for the effort in sharing your knowledge, but this is not quite what happened in the case of the OP. The question is very different. – Shahbaz Apr 29 '13 at 15:41
  • Note that [this earlier answer](http://stackoverflow.com/a/14502789/456814) already says to add the missing remote url. –  Jul 22 '14 at 00:50