Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git push error: "origin does not appear to be a git repository"

Tags:

git

git-remote

I am following the instructions given here to create a Git repository. All went well until the last line:

$ git push -u origin master  

fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

I'm using git version 1.7.11.3 on OS X 10.6.8

$ git remote -v  

returns nothing

Config file for the repository:

[core]
repositoryformatversion = 0  
filemode = true  
bare = false
logallrefupdates = true  
ignorecase = true  

I've had to open sudoers file using sudo visudo command and add the following to it (under # User privilege specification):

git ALL=(ALL) ALL.  

Now if I do:

$ git remote add origin /Volumes/500GB/git-repository/myproject.git  

it comes back with no error, but I don't see any code in the repository (it has the aforementioned directories like branches, hooks, ...)

If I do:

$ git push -u origin master  
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

$ git remote -v   
origin /Volumes/500GB/git-repository/myproject.git (fetch)     
origin /Volumes/500GB/git-repository/myproject.git (push)
like image 392
Al Lelopath Avatar asked Mar 15 '13 16:03

Al Lelopath


People also ask

How do you solve fatal origin does not appear to be a git repository?

Note: The “fatal: 'origin' does not appear to be a git repository” error occurs when you try to push code to a remote Git repository without telling Git the exact location of the remote repository. To solve this error, use the git remote add command to add a remote to your project.

Why is git push origin not working?

If git push origin master not working , all you need to do is edit that file with your favourite editor and change the URL = setting to your new location. Assuming the new repository is correctly set up and you have your URL right, you'll easily be able to push and pull to and from your new remote location.

Does not appear to be a git repo?

The “… does not a appear to be a git repository” error is triggered when you try to clone, or run other commands, in a directory that is not recognized as a Git repository. The directory or remote file path might not have initialized Git, or the file path you are trying to access as an active repository is incorrect.

How do I fix error failed to push some refs to Origin?

To fix this issue, run git pull on your local repository. This should allow you to push to origin again.


5 Answers

As it has already been mentioned in che's answer about adding the remote part, which I believe you are still missing.

Regarding your edit for adding remote on your local USB drive. First of all you must have a 'bare repository' if you want your repository to be a shared repository i.e. to be able to push/pull/fetch/merge etc..

To create a bare/shared repository, go to your desired location. In your case:

$ cd /Volumes/500gb/   
$ git init --bare myproject.git

See here for more info on creating bare repository

Once you have a bare repository set up in your desired location you can now add it to your working copy as a remote.

$ git remote add origin /Volumes/500gb/myproject.git

And now you can push your changes to your repository

$ git push origin master
like image 192
ro ko Avatar answered Oct 21 '22 23:10

ro ko


Here are the instructions from github:

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/tqisjim/google-oauth.git
git push -u origin master

Here's what actually worked:

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/tqisjim/google-oauth.git
git clone origin master

After cloning, then the push command succeeds by prompting for a username and password

like image 42
Sunny Jim Avatar answered Oct 21 '22 23:10

Sunny Jim


Most likely the remote repository doesn't exist or you have added the wrong one.

You have to first remove the origin and re-add it:

git remote remove origin
git remote add origin https://github.com/username/repository
like image 27
wanderlandderek Avatar answered Oct 21 '22 23:10

wanderlandderek


Your config file does not include any references to "origin" remote. That section looks like this:

[remote "origin"]
    url = [email protected]:repository.git
    fetch = +refs/heads/*:refs/remotes/origin/*

You need to add the remote using git remote add before you can use it.

like image 12
che Avatar answered Oct 21 '22 22:10

che


When you create a repository in bitbucket.org, it gives you instructions on how to set up your local directory. Chances are, you just forgot to run the code:

git remote add origin https://[email protected]/username/reponame.git

like image 6
Roman Avatar answered Oct 21 '22 22:10

Roman