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

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 on OS X 10.6.8

$ git remote -v  

returns nothing

Config file for the repository:

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)


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

Here are the instructions from github:

git init
git add
git commit -m "first commit"
git remote add origin
git push -u origin master

Here's what actually worked:

git init
git add
git commit -m "first commit"
git remote add origin
git clone origin master

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

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

[remote "origin"]
    url =
    fetch = +refs/heads/*:refs/remotes/origin/*

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

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

May be you forgot to run "git --bare init" on the remote? That was my problem

When you create a repository in, 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

my case was a little different - unintentionally I have changed owner of git repository (project.git directory in my case), changing owner back to the git user helped

I had this problem cause i had already origin remote defined locally. So just change "origin" into another name:

git remote add originNew

git push -u originNew

or u can remove your local origin. to check your remote name type:

git remote

to remove remote - log in your clone repository and type:

git remote remove origin(depending on your remote's name)

If you are on HTTPS do this-

git remote add origin URL_TO_YOUR_REPO

To resolving this problem.I just create a new folder and put some new files.Then use these commond.

* git add .
* git commit 
* git remote add master `your address`

then it tells me to login in. To input your username and password. after that

git pull 
git push origin master

finished you have pushed your code to your github

Need Your Help

Getting the byte bits as string

c# .net string

I want to the bits (0 or one) from a byte in a string but I don't know how?

How do I download binary files of a GitHub release?

git github binary tags release

I have a repo with binary files in it that I need.