I\'ve a repository moodle
on my Github account which I forked
from the official repository.
I then cloned it on my local machine. It worked
I had the same error on git pull origin branchname when setting the remote origin as path fs and not ssh in .git/config:
fatal: '/path/to/repo.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
It was like so (this only works for users on same server of git that have access to git):
url = file:///path/to/repo.git/
Fixed it like so (this works on all users that have access to git user (ssh authorizes_keys or password)):
url = git@domain.com:path/to/repo.git
the reason I had it as a directory path was because the git files are on the same server.
I faced the same problem when I renamed my repository on GitHub. I tried to push at which point I got the error
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
I had to change the URL using
git remote set-url origin ssh://git@github.com/username/newRepoName.git
After this all commands started working fine. You can check the change by using
git remote -v
In my case after successfull change it showed correct renamed repo in URL
[aniket@alok Android]$ git remote -v
origin ssh://git@github.com/aniket91/TicTacToe.git (fetch)
origin ssh://git@github.com/aniket91/TicTacToe.git (push)
This does not answer your question, but I faced a similar error message but due to a different reason. Allow me to make my post for the sake of information collection.
I have a git repo on a network drive. Let's call this network drive RAID. I cloned this repo on my local machine (LOCAL) and on my number crunching cluster (CRUNCHER). For convenience I mounted the user directory of my account on CRUNCHER on my local machine. So, I can manipulate files on CRUNCHER without the need to do the work in an SSH terminal.
Today, I was modifying files in the repo on CRUNCHER via my local machine. At some point I decided to commit the files, so a did a commit. Adding the modified files and doing the commit worked as I expected, but when I called git push
I got an error message similar to the one posted in the question.
The reason was, that I called push
from within the repo on CRUNCHER on LOCAL. So, all paths in the config file were plain wrong.
When I realized my fault, I logged onto CRUNCHER via Terminal and was able to push the commit.
Feel free to comment if my explanation can't be understood, or you find my post superfluous.
It is possible the other branch you try to pull from is out of synch; so before adding and removing remote try to (if you are trying to pull from master)
git pull origin master
for me that simple call solved those error messages:
Try to create remote origin first, maybe is missing because you change name of the remote repo
git remote add origin URL_TO_YOUR_REPO
$HOME/.gitconfig
is your global config for git.
There are three levels of config files.
cat $(git rev-parse --show-toplevel)/.git/config
(mentioned by bereal) is your local config, local to the repo you have cloned.
you can also type from within your repo:
git remote -v
And see if there is any remote named 'origin' listed in it.
If not, if that remote (which is created by default when cloning a repo) is missing, you can add it again:
git remote add origin url/to/your/fork
The OP mentions:
Doing
git remote -v
gives:
upstream git://git.moodle.org/moodle.git (fetch)
upstream git://git.moodle.org/moodle.git (push)
So 'origin
' is missing: the reference to your fork.
See "What is the difference between origin and upstream in github"