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

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)

Fatal error: does not appear to be a Git repository. This frustrating error is no stranger to Git users. And it can be difficult to track down a root cause if you don’t know where to start looking. But before you give up on Git, you can easily learn what causes this error, how to diagnose it, and how to avoid it in the future.

  • Learn what causes the error
  • Make sure your repository is recognized as a Git project
  • Check the file path

What Causes The “Does Not Appear To Be a Git Repository” Error?

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.

At the most basic level, Git is basically indicating that the repository you are trying to work with is unrecognizable as a Git project. This is why the error can be frustrating if you believe you have set everything up correctly. But have no fear, a simple typo may have triggered the error. Read on to learn what you can check in order to diagnose and treat this error.

What Is a Git Repository Anyway?

When working with Git repositories you are working, in essence, with directories that have been initialized as Git projects. Virtually any directory in your local computer, or on a remote server, can be initialized with Git.

In order to properly diagnose why your Git project is not accepting commands or why your remote repositories are not being recognized you must understand what Git is looking for when it is trying to interact with a repository.

New to Git? Check out the full Git guide for beginners.

Any directory, local or remote, must be initialized with Git. As you might recall, this means you must run the Git initialization command:

git init

If you have run this command in a local directory then that directory becomes a Git repository. You will see a success message indicating that the command was successful. You will also notice that all Git repositories have a .git directory where critical files and reference points are saved.

If you are initializing a remote repository, it is customary to use the --bare option:

git init --bare

This sets up a “bare” repository, which in essence is a blank directory, initialized with Git, and able to receive and run Git commands that are sent to it. Bare repositories are an ideal “hub” from which one or many Git users can clone a project, push, and pull.

Checking the File Path Of Your Remote Repository

A Git user will often encounter will encounter the “… does not appear to be a Git repository” error when trying to clone, push, or pull content from a remote repository. Be sure to check the file path of the remote repository. There are a few different ways to do that.

If you are cloning, double check to make sure that you have necessary access to the repository. Unless you are cloning a public repository on GitHub, you are likely using SSH to make the connection. Check out our full guide on setting up your remote repository with Git.

Likewise, you will want to check out the syntax of your clone command. For example, here is a basic clone command that uses HTTP to make the connection to the repository:

git clone https://github.com/WordPress/WordPress.git

If you run this command in your favorite terminal emulator it will create a directory called “WordPress” with all of the WordPress core files intact. It will also contain the .git directory, and all of the history of the project. This directory will therefore be a fully functional, local git repository. It will also have the remote repository (at GitHub) information properly set up.

But if you are reaching out to a private server that does not have HTTP access available you have to change this syntax to include a server user with appropriate privilege. (This is why when setting up a private Git server it is a good idea to create a special “Git” user with access to the repository.)

git clone [email protected]:/home/user/production.git

Notice that unlike the HTTP variation from GitHub, this clone URL contains [email protected]. The “user,” in this case, is a server user with access and privileges to interact with the Git repository on the server. The destination is the hostname, domain name, or IP address of the server you are trying to contact. Then, a colon (:) separates the user and server declaration from the file path.

The file path is critical here. The file path indicates the exact location and name of your repository. In the example above, the repository is a directory called production.git.

Always make sure to use a .git extension on your repository directory.

The production.git directory resides in the user’s home directory: /home/user.

You must reproduce this syntax precisely, otherwise you will receive the “Does not appear to be a Git repository” error.


Well done! You now know how to treat the “Does not appear to be a Git repository” error.

Let our Managed Hosting team configure your servers while you work on building your brand!

Git is a distributed version control system which is primarily used to track changes in source code during software development. GitHub is an online hosting service for version control using Git. Both these services are used extensively in Software Development. However, quite recently, a lot of reports have been coming in where users are unable to execute “git” commands in their Mac Terminal.

Fatal: ‘origin’ does not appear to be a Git Repository Error

In this article, we will talk about the reasons due to which the error is triggered and provide you with viable solutions to fix the issue. Make sure to follow the guide carefully in order to avoid conflicts.

What Causes the “Fatal: ‘origin’ does not appear to be a Git Repository” Error?

After receiving numerous reports from multiple users we decided to investigate the issue and started identifying its root cause. According to our reports, the reasons due to which this error is triggered is listed below:

  • Missing Origin: This error is usually seen when the “Origin” is missing. Origin is the reference to “Github-Fork” and if missing, some commands don’t work properly.
  • Incorrect URL: In some cases, the URL configuration set by the application might be false and it might have to be changed. Due to which, some commands might not be working properly.

Now that you have a basic understanding of the nature of the problem, we will move on towards the solutions.

Solution 1: Adding Origin

If Origin (that references to Fork) is missing certain commands might not work properly. Therefore, in this step, we will be adding an Origin manually. In order to do that:

  1. Press the “Command” + “Space” buttons simultaneously.
  2. Type in “Terminal” and press “Enter“.
    MacOS Terminal
  3. Type in the following command and press “Enter
    git remote -v
  4. Check to see if there is a remote named “Origin” listed.
  5. If not, it means that your “Origin” is missing.
  6. Add Origin using the following command
    git remote add origin url/to/your/fork
  7. Check to see if the issue persists.

Solution 2: Changing URL

If the URL is not referenced correctly it might prevent certain functions of the application from working properly. Therefore, in this step, we will be changing the URL. For that:

  1. Press the “Command” + “Space” buttons simultaneously.
  2. Type in “Terminal” and press “Enter“.
    MacOS Terminal
  3. Use the command below to change the URL
    git remote set-url origin ssh://git@github.com/username/newRepoName.git
  4. Check to see if the issue persists.

Solution 3: Changing Origin to Master

If you are trying to pull from Master, it is necessary to change the origin to master before trying to add or remove the remote. Therefore, in this step, we will be changing the Origin to Master. For that:

  1. Press the “Command” + “Space” buttons simultaneously.
  2. Type in “Terminal” and press “Enter“.
    MacOS Terminal
  3. Use the command below to change the Origin to master
    git pull origin master

Photo of Kevin Arrows

Kevin Arrows

Kevin is a dynamic and self-motivated information technology professional, with a Thorough knowledge of all facets pertaining to network infrastructure design, implementation and administration. Superior record of delivering simultaneous large-scale mission critical projects on time and under budget.

Back to top button



у меня есть репозиторий moodle на моем аккаунте Github который я forked из официального репозитория.

затем я клонировал его на моей локальной машине. Это сработало отлично. Я создал несколько ветвей (под master филиал). Я сделал несколько коммитов, и он работал нормально.

Я не знаю, как я получаю следующую ошибку, когда я делаю : git push origin master

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

как устранить ошибку, не влияя на мой репозиторий на Github?

Я использую Ubuntu 12.10

содержимое .git/config после этого cat $(git rev-parse --show-toplevel)/.git/config выдает:

[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[branch "master"]
[branch "MOODLE_23_STABLE"]
[branch "MOODLE_24_STABLE"]
[remote "upstream"]
url = git://git.moodle.org/moodle.git
fetch = +refs/heads/*:refs/remotes/upstream/*


2864  


5  

5 ответов:

$HOME/.gitconfig ваш глобальные config для git.
Есть три уровня на config файлы.

 cat $(git rev-parse --show-toplevel)/.git/config

(указано by bereal) это ваш местные config, локальный для РЕПО, которое вы клонировали.

вы также можете ввести из вашего РЕПО:

git remote -v

и посмотрите, есть ли в нем какой-либо удаленный с именем «origin».

если нет, то если что удаленный (который создается по умолчанию при клонировании РЕПО) отсутствует, вы можете добавить его снова:

git remote add origin url/to/your/fork

ОП упоминает:

делаешь git remote -v выдает:

upstream git://git.moodle.org/moodle.git (fetch) 
upstream git://git.moodle.org/moodle.git (push)

такorigin‘ отсутствует: ссылка на код вилка.
Смотрите «в чем разница между origin и upstream в github»

enter image description here

я столкнулся с той же проблемой, когда переименовал свой репозиторий на GitHub. Я попытался нажать, в какой момент я получил ошибку

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

мне пришлось изменить URL с помощью

git remote set-url origin ssh://[email protected]/username/newRepoName.git

после этого все команды начали работать нормально. Вы можете проверить изменения с помощью

git remote -v

в моем случае после успешного изменения он показал правильное переименованное РЕПО в URL

[[email protected] Android]$ git remote -v
origin  ssh://[email protected]/aniket91/TicTacToe.git (fetch)
origin  ssh://[email protected]/aniket91/TicTacToe.git (push)

возможно, другая ветвь, из которой вы пытаетесь вытащить, не синхронизирована; поэтому перед добавлением и удалением remote попробуйте (если вы пытаетесь вытащить из master)

git pull origin master

для меня этот простой вызов решил эти сообщения об ошибках:

  • fatal: ‘master’ не является репозиторием git
  • fatal: не удалось прочитать из удаленного репозитория.

это не ответ на ваш вопрос, но я столкнулся с аналогичным сообщением об ошибке, но по другой причине. Позвольте мне сделать свой пост ради сбора информации.

у меня есть git РЕПО на сетевом диске. Давайте назовем этот сетевой диск RAID. Я клонировал это РЕПО на моей локальной машине (LOCAL) и на моем номере crunching cluster (CRUNCHER).
Для удобства я смонтировал каталог пользователя моей учетной записи на CRUNCHER на моей локальной машине. Итак, я могу манипулировать файлами на CRUNCHER без необходимости выполнять работу в SSH-терминале.

сегодня я изменял файлы в РЕПО на CRUNCHER через мою локальную машину. В какой-то момент я решил зафиксировать файлы, поэтому a сделал фиксацию. Добавление измененных файлов и выполнение фиксации работали так, как я ожидал, но когда я позвонил git push Я получил сообщение об ошибке, подобное тому, которое было опубликовано в вопросе.

причина была в том, что я назвал push из РЕПО на CRUNCHER на локальном. Итак, все пути в конфигурации файл был просто неправильным.

когда я понял свою ошибку, я вошел в CRUNCHER через терминал и смог нажать фиксацию.

Не стесняйтесь комментировать, если мое объяснение не может быть понята, или вы найдете мой пост лишним.

у меня была такая же ошибка на git pull origin branchname при установке удаленного источника в качестве пути fs, а не ssh на .git / config:

fatal: '/path/to/repo.git' does not appear to be a git repository 
fatal: The remote end hung up unexpectedly

Это было так (это работает только для пользователей на том же сервере git, которые имеют доступ к Git):

url = file:///path/to/repo.git/

исправил вроде так (это работает на всех пользователей, которые имеют доступ к git user (ssh authorizes_keys или пароль)):

url = [email protected]:path/to/repo.git

причина, по которой у меня был путь к каталогу, заключалась в том, что git файлы находятся на одном сервере.

Fatal: Origin Does Not Appear to Be a Git Repository Error in Git

This article outlines the steps necessary to solve the fatal: 'origin' does not appear to be a git repository error in Git. This error is associated with the git push origin <branch-name> command.

Here are some of the most probable causes of the fatal: 'origin' does not appear to be a git repository error.

  1. Your remote fork (origin) might be missing.
  2. Your remote’s URL configuration might have changed.

If you initialize a local repo with the git init command and fail to link the repo with a remote repository, you will get the same error if you attempt to push the changes.

fatal error in git

Fix the fatal: 'origin' does not appear to be a git repository Error in Git

We now know why this error pops up on Git. How do we fix it?

We first need to check if our local repository has an origin. We will run the command below.

If you can’t see the origin listed in the output, your origin remote repo might be missing, or you did not link your local repo with a remote repository.

To set it up, go to your GitHub account where the remote repository is located and follow the steps below.

  1. On your GitHub account, go to Repositories and select the repository you want to link your local repo.

    GitHub Repositories

  2. Click on Code and copy the link to your repository.

    copy link

  3. On the Git terminal, run the command below to add origin to your repo.

    $ git remote add origin<URL>
    

    In our case:

    $ git remote add origin https://github.com/Wachira11ke/Git-Tutorials.git
    

As shown below, we can run the git branch command to check for remote branches in our repo.

Output:

* master
  remotes/origin/master

As shown below, we can now push our code by running the git push origin master command.

git push

The command above will push to our origin and create a branch called master.

If the issue persists, your URL might not be referenced correctly. We can run the command shown below to rectify this issue.

$ git remote set-url origin ssh://git@github.com/gitusername/newRepositoryName.git

You can also change your master to origin if the above methods do not help. Just run:

In conclusion, we have covered three methods you can use to solve the error mentioned above on Git. Always link a local repo with a remote repo before pushing code.

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account


Closed

kervin521 opened this issue

Jun 27, 2018

· 7 comments

Comments

@kervin521

$ git push origin master
fatal: ‘origin’ does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

@ttaylorr

Hi @kervin521, thanks for opening this issue. Please make sure that you have a valid repository configured as your remote named ‘origin’. You can see what URL a remote is set to track with the command git remote -v, and you can change the url with git remote set-url origin <url>.

Please let me know if you have any other issues.

@armanriazi

if still keep problem you try:
git push -f origin master

@a4anj

Same issue tried both of the above. Not working.

@bk2204

Hey,

This is a Git error not specific to Git LFS and what @ttaylorr said is correct: your remote repository location isn’t valid. Trying a force push won’t change that. You would need to fix the URL or path such that it points to a valid location.

@davik4life

A much more clever approach to solving the issue as an addon to @ttaylorr suggestion is to do the following.

  1. git remote add origin <yourGitRepoSSHLink>
  2. git remote -v
    If you find the fetch and push with a preceding origin returned, then it’s fixed.

Do some edits and push using git push origin main or git push origin master

Hope this helps, Good luck.

@Martin-Maat

None of this worked for me. Using Git Server on a Synology. It’s been a horrible experience so far.

@KirillMos1

Hello! Please tell me why I enter «git push assistant main» (I have an assistant repository) and I get the error «fatal: ‘assistant’ does not seem to be a git repository
fatal: could not be read from a remote repository.

Please make sure that you have the correct access rights
and the repository exists.» What does it mean? Thanks. If anything, I don’t understand English.

I set up a empty git repo on my production server with

git init --bare

From my local machine i added the repo as a remote:

git remote add origin ssh://user@example.com/~/git/example.com

If i issue following command

git remote show origin

I get an error message saying:

fatal: '~/git/example.com' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

I tried the colon as mentioned here, but it didn’t help.

Community's user avatar

asked Jun 19, 2015 at 10:37

Mario's user avatar

2

With SSH URLs, relative paths start from your home directory, and it doesn’t understand shell shortcuts like ~. So do:

git remote add origin ssh://user@example.com/git/example.com

if you want to use absolute paths, like /home/mario/git/example.com, use an extra leading slash:

git remote add origin ssh://user@example.com//home/mario/git/example.com

answered Jun 19, 2015 at 10:57

muru's user avatar

murumuru

189k52 gold badges460 silver badges711 bronze badges

1

This means that the remote server does not have a repo at ~/git/example.com I suspect you have the address wrong. Most git addresses will be something like git@server.com:project.git. Most do not have a path or a reference to ~

answered Jun 19, 2015 at 10:46

coteyr's user avatar

coteyrcoteyr

17.5k6 gold badges29 silver badges57 bronze badges

I have the answer to my own problem…

I am using the URL conventions used in this post

The Domain i was using was just defined in my local hosts file. Which seems to work with everything else, accept for git.

I then replaced the example.com part with the actual Server IP and got it working.

Community's user avatar

answered Jun 20, 2015 at 12:05

Mario's user avatar

MarioMario

611 gold badge1 silver badge3 bronze badges

Понравилась статья? Поделить с друзьями:
  • Dodge caliber ошибка p0481
  • Dod ls400w ошибка памяти
  • Document was not saved because there was an error writing the file sfm что делать
  • Document was not opened because there was an error reading the file sfm
  • Document ready error