fatal remote origin already exists что делать

Fatal remote origin already exists что делать

Ключевое слово «origin» обычно используется для описания центрального источника (ресурса на сервере) репозитория Git. Если Вы попытаетесь добавить удаленный сервер (remote), так называемый «origin» к репозиторию, в котором описание origin уже существует, то получите ошибку «fatal: remote origin already exists». В этой статье (перевод [1]) мы обсудим подобный случай проблемы «fatal: remote origin already exists» и способ её решения.

Если «origin» URL не соответствует URL Вашего remote-репозитория, к которому Вы хотите обратиться, то можно поменять remote URL. Альтернативно можно удалить remote, и заново установить remote URL с именем «origin».

Пример проблемной ситуации. У нас есть некий репозиторий с именем «git», и мы хотим поменять его текущий origin:

Чтобы сделать это, мы используем команду git remote add command, который добавляет новый remote к репозиторию:

Но эта команда вернула ошибку:

Этим сообщением git говорит нам, что remote origin уже существует.

Способ решения проблемы. Мы не можем добавить новый remote, используя имя, которое уже используется, даже если мы указываем для remote новый URL. В этом случае мы попытались создать новый remote с именем «origin», когда remote с таким именем уже существует. Чтобы исправить эту ошибку, мы должны удалить существующий remote, который называется «origin», и добавить новый, либо должны поменять URL существующего remote.

Чтобы удалить существующий remote и добавить новый, мы можем установить новый URL для нашего remote:

Это предпочтительный метод, потому что мы можем в одной команде поменять URL, связанный с нашим remote. Не понадобится уделить старый origin и создавать новый, потому что существует команда set-url.

Альтернативно мы можем удалить наш remote «origin», и после этого создать новый, с новым URL:

Этот метод использует 2 команды вместо одной.

Источник

What «Remote Origin Already Exists» Error Means and How To Fix It

April 30
Stay connected

Do you write code for a living? Then learn Git, and learn it well. The tool originally created by Linus Torvalds—yes, the creator of the Linux kernel—has become the de facto standard when it comes to source control solutions. To help you along your learning journey, we’ve been covering common Git pitfalls and explaining how to get out of them.

Today, we’ll add another installment to the series by covering an issue you might bump into when following Git tutorials over the web: the «remote origin already exists» error. As far as Git error messages go, this one is pretty straightforward, unlike other weirder messages. It clearly states what the problem is: you’re trying to add a remote called origin, but you already have one with that name. That’s not that different from your operating system preventing you from creating a file with the same name as an already existing file.

In this post, we’ll give more detail into why that error message happens in the first place and then show you a few different ways in which you can address it. Let’s dig in.

«Remote Origin Already Exists» Error: Why Does It Happen?

Picture this: You’re following a Git tutorial you’ve found online. So far everything works fine. Then, you see a line similar to the following one:

After trying to execute the command above, you get the infamous error message:

fatal: remote origin already exists.

Understanding this message is actually easy. Unlike centralized VCSs, Git doesn’t have a central server. In Git, you can have what we call remote repositories, or simply remotes. Remotes represent repositories that you might have read and/or write access to. Those are usually on machines other than your own, and you access them via SSH or HTTP. Keep in mind that, despite the name, remotes aren’t necessarily located on remote machines: despite sounding like an oxymoron, local remotes are totally possible.

Remotes have names to identify them, and you can have as many remotes per repository as you need or want. However, you can’t have two remotes with the same name. So if you try to add a remote with the same name as an already existing remote, boom! Fatal error.

If you want to be really sure the remote called origin actually exists, you can easily check that by running the following command:

That will make your Git list all existing remotes for the current repository. If you want to get more detail, you can add the verbose parameter with the remote command, like this:

That will return not only the names of each remote but also its URLs:

By the way, the message will not always contain the actual word «origin.» Let’s say you’re trying to add a remote called cloudbees but there’s already a remote with that name. In this case, the error message would say:

fatal: remote cloudbees already exists.

Similarly to the way that the default branch in Git is called controller—though that could change in the near future—the default remote is called origin, but you could name it anything you like as long as it’s a legal name in Git.

Solving the «Remote Origin Already Exists» Error in Four Different Ways

Having explained why the error message happens, we’ll now cover some of the several potential solutions you can use to solve the problem. Keep in mind that the solution you’ll use will depend on your specific situation because there are a few different scenarios that can cause this problem to happen.

1. Remove the Existing Remote

The first scenario we’ll cover is the one in which there’s already a remote called origin, but it’s the wrong remote for some reason. Let’s say, for the sake of the example, that you used to use GitLab for storing your repositories online and then decided to switch over to GitHub (or vice versa). To go about that, you could follow the steps below:

Create a new repository online using GitHub or GitLab.

Go to your local repository and remove the existing origin remote.

Add the new online repository as the correct origin remote.

Push your code to the new origin.

If, for some reason, you skip step #2, that will cause Git to display the «remote origin already exists» message. So a possible solution here would be simply removing the existing remote:

git remote remove origin

As explained before, origin is just a name for a remote. It could be a different name for you. To make sure the remote is indeed deleted, you can use the Git remote command you saw earlier. Then, if everything is all right, you can go on to adding the desired remote.

2. Update the Existing Remote’s URL

We’ve just shown you how to remove an existing remote, so you can hopefully add a new one, this time with the correct URL. However, you might be thinking that removing the remote and adding it again with a different link will have an eerily similar result as updating the URL of the existing remote. If that’s the case, you’re right, of course.

So let’s see how to achieve the same result we got in the previous section but in a faster way. You just have to use a single command:

As we’ve said before, we keep talking about origin throughout this post, but there’s nothing preventing you from working with whatever remote names you feel like. So a complete example with origin as the remote name and a URL to a real repo could look like this:

git remote set-url origin https://github.com/git/git.git

3. Rename the Existing Remote

Let’s say that, for whatever reason, you already have a remote called origin. You want to add a new origin, but you also need to keep the old one. How would you go about it?

Easy. Rename the existing remote before adding the new one. Just run the following command and you’re set:

So let’s say you want to rename your origin remote to backup. You’d simply run:

git remote rename origin backup

Then you can add your new remote called origin normally, and you should no longer see the «remote origin already exists» error.

4. Do Nothing!

This is not a joke, I promise you. Here’s the thing: Sometimes, you might get the «remote origin already exists» error when following a tutorial that has some step asking you to add a remote called origin. If you try to run the command and get the error message, it’s possible that you’ve already executed that command and don’t remember.

To check whether that’s really the case, you can use the Git remote command with the verbose option, as we’ve covered before:

That will allow you to see the existing remotes along with the URLs they point to. If the existing remote already has the same URL provided by the tutorial, that means your repo is ready to go and you don’t need to do anything else.

«Remote Origin Already Exists» Scaring You? A Thing of the Past

Git is an essential tool in the modern software developer’s tool belt. Unfortunately, many developers consider Git a hard tool to learn. There’s some truth to those claims. Though the basic Git commands you’ll use most of the time are easy to learn and understand, you might stumble upon a particularly difficult aspect of the tool from time to time. For instance, you might find yourself with a somewhat bizarre error message. Or the various ways in which Git allows you to go back and change things might trip you up a bit.

In today’s post, we’ve covered a fairly common Git error message. Hopefully, you’re now ready to address this error when it comes your way.

If there’s one takeaway you get from this post, we hope it’s this: Even though Git can sometimes feel daunting, it’s actually not that hard once you get used to some of its UI quirks and get somewhat familiar with its fundamentals. So keep studying and keep practicing, and then using Git will feel like second nature in no time.

Источник

I can not create origin remotely with remote command:

To solve the error, I have tried this:

It is not uploading the files from my local repository to the remote:

Does each repository have its own origin?

Solution: I was using the Powershell that came with Github or Git Shell as it is also called to do my tutorial, once I switched to Git Bash it worked fine.

4 Answers 4

That will replace the current origin with a new one.

fatal remote origin already exists что делать. Смотреть фото fatal remote origin already exists что делать. Смотреть картинку fatal remote origin already exists что делать. Картинка про fatal remote origin already exists что делать. Фото fatal remote origin already exists что делать

git remote rm origin

git remote add origin https://yourLink

I had a similar issue but I got it resolved using:

In order to use git push, you must specify final destination follorwed by local_branch ( in my own case, it is master for the local branch and main for the remote branch). They could however be the same. As in:

It’s quite strange as to why your origin doesn’t have a value. Typically, it should look like this:

Your origin doesn’t have the url associate with it. It’s actually name value pair. So when you say «git push origin master», Git substitues the value of origin. In my case, it would be «/mnt/temp.git».

1) Clone the repository in another directory.

4) So come back to your working directory, and run » git remote add origin2 https://github.com/LongKnight/git-basics.git «

5) Run » git remote remove origin «

6) Now run » git remote rename origin2 origin «

8) It should be correctly set now. If so, run » git push «

Источник

Remote origin already exists on ‘git push’ to a new repository

I used the command:

but I am receiving this:

fatal: remote origin already exists.

fatal remote origin already exists что делать. Смотреть фото fatal remote origin already exists что делать. Смотреть картинку fatal remote origin already exists что делать. Картинка про fatal remote origin already exists что делать. Фото fatal remote origin already exists что делать

20 Answers 20

You are getting this error because «origin» is not available. «origin» is a convention not part of the command. «origin» is the local name of the remote repository.

For example you could also write:

To remove a remote repository you enter:

Again «origin» is the name of the remote repository if you want to remove the «upstream» remote:

You can change the remote origin in your Git configuration with the following line:

This command sets a new URL for the Git repository you want to push to. Important is to fill in your own username and projectname

fatal remote origin already exists что делать. Смотреть фото fatal remote origin already exists что делать. Смотреть картинку fatal remote origin already exists что делать. Картинка про fatal remote origin already exists что делать. Фото fatal remote origin already exists что делать

If you have mistakenly named the local name as «origin», you may remove it with the following:

METHOD1->

Since origin already exist remove it.

METHOD2->

If you’re updating to use HTTPS

If you’re updating to use SSH

If trying to update a remote that doesn’t exist you will receive a error. So be careful of that.

METHOD3->

Use the git remote rename command to rename an existing remote. An existing remote name, for example, origin.

To verify remote’s new name->

If new to Git try this tutorial->

fatal remote origin already exists что делать. Смотреть фото fatal remote origin already exists что делать. Смотреть картинку fatal remote origin already exists что делать. Картинка про fatal remote origin already exists что делать. Фото fatal remote origin already exists что делать

You can simply edit your configuration file in a text editor.

/.gitconfig you need to put in something like the following:

In the oldrep/.git/config file (in the configuration file of your repository):

If there is a remote section in your repository’s configuration file, and the URL matches, you need only to add push configuration. If you use a public URL for fetching, you can put in the URL for pushing as ‘pushurl’ (warning: this requires the just-released Git version 1.6.4).

fatal remote origin already exists что делать. Смотреть фото fatal remote origin already exists что делать. Смотреть картинку fatal remote origin already exists что делать. Картинка про fatal remote origin already exists что делать. Фото fatal remote origin already exists что делать

git remote rm origin

git remote add origin git@github.com:username/myapp.git

git push origin master It will start the process and creating the new branch. You can see your work is pushed to github.

fatal remote origin already exists что делать. Смотреть фото fatal remote origin already exists что делать. Смотреть картинку fatal remote origin already exists что делать. Картинка про fatal remote origin already exists что делать. Фото fatal remote origin already exists что делать

You don’t have to remove your existing «origin» remote, just use a name other than «origin» for your remote add, e.g.

git remote add github git@github.com:myname/oldrep.git

I had the same issue, and here is how I fixed it, after doing some research:

If it’s not connected, it might show origin only.

Now remove the remote repository from the local repository by using

Now that your old remote repository is disconnected, you can add the new remote repository. Use the following to connect to your new repository:

Note: In case you are using Bitbucket, you would create a project on Bitbucket first. After creation, Bitbucket will display all required Git commands to push your repository to remote, which look similar to the next code snippet. However, this works for other repositories as well.

Источник

GitHub » fatal: удаленное происхождение уже существует»

Я пытаюсь следовать вдоль учебник Майкла Хартла по рельсам но я столкнулся с ошибкой.

Я зарегистрировался на Github и выпустил новый SSH-ключ и создал новый репозиторий. Но когда я ввожу следующую строку в терминал, я получаю следующую ошибку:

просто интересно, кто-нибудь еще сталкивался с этой проблемой?

15 ответов

TL; DR вы должны просто обновить существующий пульт дистанционного управления:

версия:

как указывает сообщение об ошибке, уже есть удаленный настроенный с тем же именем. Таким образом, вы можете добавить новый пульт с другим именем или обновить существующий, если он вам не нужен:

чтобы добавить новый пульт дистанционного управления, например github вместо origin (который, очевидно, уже существует в системе), выполнить следующий:

для тех из вас, кто сталкивается с очень распространенной ошибкой » fatal: remote origin уже существует.», или при попытке удалить origin и вы получаете » ошибка: не удалось удалить раздел конфигурации remote.origin», что вам нужно сделать, это установить origin вручную.

Git окна для Windows PowerShell (и приложение GitHub для Windows) имеет проблему с этим.

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

во-первых, проверьте свои пульты:

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

Итак, измените url вручную:

это исправило десятки репозиториев git, с которыми у меня были проблемы, GitHub, BitBucket GitLab и т. д.

вы можете увидеть, какие удаленные репозитории вы настроены для подключения через

это вернет список в этом формате:

это может помочь вам понять, на что указывало первоначальное «происхождение».

если вы хотите сохранить удаленное соединение, которое вы видите с-v, но все же хотите следовать учебнику Rails без необходимости запоминать «github» (или какое-либо другое имя) для РЕПО вашего учебника, вы можете переименовать свой другое репозиторий с помощью команды:

вы должны быть в состоянии возобновить учебник.

сначала сделайте a:

и вуаля! Работал на меня!

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

а затем перезапустите новый репозиторий git, как обычно:

Если вам нужно проверить, какие удаленные репозитории вы подключили к локальным репозиториям, theres cmd:

теперь, если вы хотите удалить удаленное РЕПО (скажем, origin), то вы можете сделать следующее:

на origin это псевдоним указывая на этот URL. Поэтому вместо того, чтобы писать весь URL каждый раз, когда мы хотим что-то отправить в наш репозиторий, мы просто используем этот псевдоним и запускаем:

говорить git to push наш код от нашего местные мастер филиала до пульт ДУ origin хранилище.

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

в любом случае, мы всегда можем изменить это имя на что угодно, запустив это:

так как он хранится на стороне клиента git применение (на нашей машине) изменяя его не будет повлиять на что-либо в нашем процессе разработки, ни в нашем удаленном репозитории. Помните, что это только имя указала на адрес.

единственное, что меняется здесь, переименовывая псевдоним, это то, что мы должны объявить это новое имя каждый раз, когда мы нажимаем что-то в наше хранилище.

очевидно, что одно имя не может указывать на два разных адреса. Вот почему вы получаете это сообщение об ошибке. Уже есть псевдоним с именем origin на локальной машине. Чтобы узнать, сколько псевдонимов у вас и каковы они, вы можете инициировать эту команду:

это покажет вам все псевдонимы у вас плюс соответствующие url.

вы также можете удалить их, если вам нравится запускать это:

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *