I have my project on GitHub at some location, git@github.com:myname/oldrep.git
.
Now I want to push all my code to a new repository at some other location, git@github.com:newname/newrep.git
.
I used the command:
git remote add origin git@github.com:myname/oldrep.git
but I am receiving this:
fatal: remote origin already exists.
vvvvv
21.1k17 gold badges46 silver badges66 bronze badges
asked Aug 3, 2009 at 11:32
uzumaki narutouzumaki naruto
6,8693 gold badges17 silver badges12 bronze badges
5
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:
git remote add myorigin git@github.com:myname/oldrep.git
git remote add testtest git@github.com:myname/oldrep.git
See the manual:
http://www.kernel.org/pub/software/scm/git/docs/git-remote.html
To remove a remote repository you enter:
git remote rm origin
Again «origin» is the name of the remote repository if you want to
remove the «upstream» remote:
git remote rm upstream
answered Aug 3, 2009 at 11:41
7
The previous solutions seem to ignore origin, and they only suggest to use another name. When you just want to use git push origin
, keep reading.
The problem appears because a wrong order of Git configuration is followed. You might have already added a ‘git origin’ to your .git configuration.
You can change the remote origin in your Git configuration with the following line:
git remote set-url origin git@github.com:username/projectname.git
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
answered Apr 5, 2012 at 11:49
HoetmaaiersHoetmaaiers
3,3532 gold badges19 silver badges29 bronze badges
4
If you have mistakenly named the local name as «origin», you may remove it with the following:
git remote rm origin
answered Aug 13, 2010 at 11:45
ÖzgürÖzgür
7,9992 gold badges68 silver badges66 bronze badges
2
METHOD1->
Since origin already exist remove it.
git remote rm origin
git remote add origin https://github.com/USERNAME/REPOSITORY.git
METHOD2->
One can also change existing remote repository URL by ->git remote set-url
If you’re updating to use HTTPS
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
If you’re updating to use SSH
git remote set-url origin git@github.com:USERNAME/REPOSITORY.git
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.
git remote rename origin startpoint
# Change remote name from 'origin' to 'startpoint'
To verify remote’s new name->
git remote -v
If new to Git try this tutorial->
TRY GIT TUTORIAL
answered Jun 23, 2017 at 11:10
0
You can simply edit your configuration file in a text editor.
In the ~/.gitconfig
you need to put in something like the following:
[user]
name = Uzumaki Naruto
email = myname@example.com
[github]
user = myname
token = ff44ff8da195fee471eed6543b53f1ff
In the oldrep/.git/config
file (in the configuration file of your repository):
[remote "github"]
url = git@github.com:myname/oldrep.git
push = +refs/heads/*:refs/heads/*
push = +refs/tags/*:refs/tags/*
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).
answered Aug 3, 2009 at 19:05
Jakub NarębskiJakub Narębski
301k65 gold badges219 silver badges230 bronze badges
I had the same issue, and here is how I fixed it, after doing some research:
- Download GitHub for Windows, or use something similar, which includes a shell.
- Open the
Git Shell
from the task menu. This will open a power shell including Git commands. - In the shell, switch to your old repository, e.g.
cd C:pathtooldrepository
. - Show the status of the old repository.
-
Type
git remote -v
to get the remote path for fetch and push remote. If your local repository is connected to a remote, it will show something like this:origin https://user@bitbucket.org/team-or-user-name/myproject.git (fetch) origin https://user@bitbucket.org/team-or-user-name/myproject.git (push)
-
If it’s not connected, it might show
origin
only.
-
Now remove the remote repository from the local repository by using
git remote rm origin
-
Check again with
git remote -v
, as in step 4. It should showorigin
only, instead of the fetch and push path. -
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.
cd /path/to/my/repo # If you haven't done that yet.
git remote add mynewrepo https://user@bitbucket.org/team-or-user-name/myproject.git
git push -u mynewrepo master # To push changes for the first time.
That’s it.
Dmitri
2,6382 gold badges23 silver badges40 bronze badges
answered Jan 23, 2014 at 13:28
MichaelMichael
3,9424 gold badges30 silver badges46 bronze badges
-
git remote rm origin
-
git remote -v
It will not display any repository name -
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.
answered Aug 10, 2018 at 10:54
devdev
1911 silver badge11 bronze badges
git remote rm origin
git remote add origin git@github.com:username/myapp.git
answered Apr 8, 2017 at 9:54
AayushiAayushi
77710 silver badges14 bronze badges
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
answered Feb 15, 2012 at 22:39
The below two commands should help set up.
git remote set-url origin https://github.com/USERNAME/NEW_REPO.git
git push --set-upstream origin main
buddemat
3,89612 gold badges23 silver badges47 bronze badges
answered Feb 1, 2022 at 20:07
Mansi ShahMansi Shah
1271 silver badge5 bronze badges
I had the same problem when I first set up using Bitbucket.
My problem was that I needed to change the word origin for something self-defined. I used the name of the application. So:
git remote add AppName https://someone@bitbucket.org/somewhere/something.git
answered Apr 9, 2014 at 9:44
Michael MurphyMichael Murphy
1,8512 gold badges17 silver badges21 bronze badges
You should change the name of the remote repository to something else.
git remote add origin git@github.com:myname/oldrep.git
to
git remote add neworigin git@github.com:myname/oldrep.git
I think this should work.
Yes, these are for repository init and adding a new remote. Just with a change of name.
answered May 3, 2014 at 14:49
nirvanastacknirvanastack
4552 gold badges5 silver badges13 bronze badges
You could also change the repository name you wish to push to in the REPOHOME/.git/config file
(where REPOHOME is the path to your local clone of the repository).
answered Aug 3, 2009 at 12:57
nolim1tnolim1t
3,9431 gold badge16 silver badges7 bronze badges
You need to check the origin
and add if not exists.
if ! git config remote.origin.url >/dev/null; then
git remote add origin git@github.com:john/doe.git
fi
Create file check.sh
, paste the script update your git repository URL and run ./check.sh
.
answered Jan 6, 2020 at 9:18
Madan SapkotaMadan Sapkota
24.5k11 gold badges112 silver badges117 bronze badges
This can also happen when you forget to make a first commit.
answered Jun 23, 2017 at 3:39
Clay MortonClay Morton
3352 silver badges15 bronze badges
I had the same issue but I found the solution to it. Basically «origin» is another name from where your project was cloned. Now the error
fatal: remote origin already exists.
LITERALLY means origin already exists. And hence to solve this issue, our goal should be to remove it.
For this purpose:
git remote rm origin
Now add it again
git remote add origin https://github.com/__enter your username here__/__your repositoryname.git__
This did fix my issue.
answered Oct 6, 2020 at 14:03
I just faced this issue myself and I just removed it by removing the origin.
the origin
is removed by this command
git remote rm origin
if you’ve added the remote repo as origin
try implementing this command.
lys
8192 gold badges10 silver badges33 bronze badges
answered Feb 25, 2021 at 7:58
Try to remove first existing origin, In order to see the which existing origin has registered with bash you can fire below command.
git remote -v
after you know the which version of origin has register with bash then you can remove existing origin by firing below command
git remote rm origin
Once you removed existing origin you can add new origin by firing below command in you case ..
git remote add origin git@github.com:myname/oldrep.git
Once you add your origin in git, then you can push your local commit to remote origin
git push -u origin --all
answered Jul 24, 2021 at 22:20
Step:1
git remote rm origin
Step:2
git remote add origin enter_your_repository_url
Example:
git remote add origin https://github.com/my_username/repository_name.git
answered May 6, 2020 at 5:48
if you want to create a new repository with the same project inside the github and the previous Remote is not allowing you to do that in that case First Delete That Repository on github then you simply need to delete the .git folder C:UsersShivaAndroidStudioProjectsyourprojectname.git delete that folder,(make sure you click on hidden file because this folder is hidden )
Also click on the minus(Remove button) from the android studio Setting->VersionControl
click here for removing the Version control from android And then you will be able to create new Repository.
answered Jun 3, 2020 at 13:24
Try this command it works for me.
rm -rf .git/
answered Jun 8, 2022 at 4:39
git remote rm origin
and then
git push -f
answered Mar 24, 2022 at 16:03
RasikhRasikh
111 silver badge2 bronze badges
3
I have my project on GitHub at some location, git@github.com:myname/oldrep.git
.
Now I want to push all my code to a new repository at some other location, git@github.com:newname/newrep.git
.
I used the command:
git remote add origin git@github.com:myname/oldrep.git
but I am receiving this:
fatal: remote origin already exists.
vvvvv
21.1k17 gold badges46 silver badges66 bronze badges
asked Aug 3, 2009 at 11:32
uzumaki narutouzumaki naruto
6,8693 gold badges17 silver badges12 bronze badges
5
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:
git remote add myorigin git@github.com:myname/oldrep.git
git remote add testtest git@github.com:myname/oldrep.git
See the manual:
http://www.kernel.org/pub/software/scm/git/docs/git-remote.html
To remove a remote repository you enter:
git remote rm origin
Again «origin» is the name of the remote repository if you want to
remove the «upstream» remote:
git remote rm upstream
answered Aug 3, 2009 at 11:41
7
The previous solutions seem to ignore origin, and they only suggest to use another name. When you just want to use git push origin
, keep reading.
The problem appears because a wrong order of Git configuration is followed. You might have already added a ‘git origin’ to your .git configuration.
You can change the remote origin in your Git configuration with the following line:
git remote set-url origin git@github.com:username/projectname.git
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
answered Apr 5, 2012 at 11:49
HoetmaaiersHoetmaaiers
3,3532 gold badges19 silver badges29 bronze badges
4
If you have mistakenly named the local name as «origin», you may remove it with the following:
git remote rm origin
answered Aug 13, 2010 at 11:45
ÖzgürÖzgür
7,9992 gold badges68 silver badges66 bronze badges
2
METHOD1->
Since origin already exist remove it.
git remote rm origin
git remote add origin https://github.com/USERNAME/REPOSITORY.git
METHOD2->
One can also change existing remote repository URL by ->git remote set-url
If you’re updating to use HTTPS
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
If you’re updating to use SSH
git remote set-url origin git@github.com:USERNAME/REPOSITORY.git
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.
git remote rename origin startpoint
# Change remote name from 'origin' to 'startpoint'
To verify remote’s new name->
git remote -v
If new to Git try this tutorial->
TRY GIT TUTORIAL
answered Jun 23, 2017 at 11:10
0
You can simply edit your configuration file in a text editor.
In the ~/.gitconfig
you need to put in something like the following:
[user]
name = Uzumaki Naruto
email = myname@example.com
[github]
user = myname
token = ff44ff8da195fee471eed6543b53f1ff
In the oldrep/.git/config
file (in the configuration file of your repository):
[remote "github"]
url = git@github.com:myname/oldrep.git
push = +refs/heads/*:refs/heads/*
push = +refs/tags/*:refs/tags/*
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).
answered Aug 3, 2009 at 19:05
Jakub NarębskiJakub Narębski
301k65 gold badges219 silver badges230 bronze badges
I had the same issue, and here is how I fixed it, after doing some research:
- Download GitHub for Windows, or use something similar, which includes a shell.
- Open the
Git Shell
from the task menu. This will open a power shell including Git commands. - In the shell, switch to your old repository, e.g.
cd C:pathtooldrepository
. - Show the status of the old repository.
-
Type
git remote -v
to get the remote path for fetch and push remote. If your local repository is connected to a remote, it will show something like this:origin https://user@bitbucket.org/team-or-user-name/myproject.git (fetch) origin https://user@bitbucket.org/team-or-user-name/myproject.git (push)
-
If it’s not connected, it might show
origin
only.
-
Now remove the remote repository from the local repository by using
git remote rm origin
-
Check again with
git remote -v
, as in step 4. It should showorigin
only, instead of the fetch and push path. -
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.
cd /path/to/my/repo # If you haven't done that yet.
git remote add mynewrepo https://user@bitbucket.org/team-or-user-name/myproject.git
git push -u mynewrepo master # To push changes for the first time.
That’s it.
Dmitri
2,6382 gold badges23 silver badges40 bronze badges
answered Jan 23, 2014 at 13:28
MichaelMichael
3,9424 gold badges30 silver badges46 bronze badges
-
git remote rm origin
-
git remote -v
It will not display any repository name -
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.
answered Aug 10, 2018 at 10:54
devdev
1911 silver badge11 bronze badges
git remote rm origin
git remote add origin git@github.com:username/myapp.git
answered Apr 8, 2017 at 9:54
AayushiAayushi
77710 silver badges14 bronze badges
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
answered Feb 15, 2012 at 22:39
The below two commands should help set up.
git remote set-url origin https://github.com/USERNAME/NEW_REPO.git
git push --set-upstream origin main
buddemat
3,89612 gold badges23 silver badges47 bronze badges
answered Feb 1, 2022 at 20:07
Mansi ShahMansi Shah
1271 silver badge5 bronze badges
I had the same problem when I first set up using Bitbucket.
My problem was that I needed to change the word origin for something self-defined. I used the name of the application. So:
git remote add AppName https://someone@bitbucket.org/somewhere/something.git
answered Apr 9, 2014 at 9:44
Michael MurphyMichael Murphy
1,8512 gold badges17 silver badges21 bronze badges
You should change the name of the remote repository to something else.
git remote add origin git@github.com:myname/oldrep.git
to
git remote add neworigin git@github.com:myname/oldrep.git
I think this should work.
Yes, these are for repository init and adding a new remote. Just with a change of name.
answered May 3, 2014 at 14:49
nirvanastacknirvanastack
4552 gold badges5 silver badges13 bronze badges
You could also change the repository name you wish to push to in the REPOHOME/.git/config file
(where REPOHOME is the path to your local clone of the repository).
answered Aug 3, 2009 at 12:57
nolim1tnolim1t
3,9431 gold badge16 silver badges7 bronze badges
You need to check the origin
and add if not exists.
if ! git config remote.origin.url >/dev/null; then
git remote add origin git@github.com:john/doe.git
fi
Create file check.sh
, paste the script update your git repository URL and run ./check.sh
.
answered Jan 6, 2020 at 9:18
Madan SapkotaMadan Sapkota
24.5k11 gold badges112 silver badges117 bronze badges
This can also happen when you forget to make a first commit.
answered Jun 23, 2017 at 3:39
Clay MortonClay Morton
3352 silver badges15 bronze badges
I had the same issue but I found the solution to it. Basically «origin» is another name from where your project was cloned. Now the error
fatal: remote origin already exists.
LITERALLY means origin already exists. And hence to solve this issue, our goal should be to remove it.
For this purpose:
git remote rm origin
Now add it again
git remote add origin https://github.com/__enter your username here__/__your repositoryname.git__
This did fix my issue.
answered Oct 6, 2020 at 14:03
I just faced this issue myself and I just removed it by removing the origin.
the origin
is removed by this command
git remote rm origin
if you’ve added the remote repo as origin
try implementing this command.
lys
8192 gold badges10 silver badges33 bronze badges
answered Feb 25, 2021 at 7:58
Try to remove first existing origin, In order to see the which existing origin has registered with bash you can fire below command.
git remote -v
after you know the which version of origin has register with bash then you can remove existing origin by firing below command
git remote rm origin
Once you removed existing origin you can add new origin by firing below command in you case ..
git remote add origin git@github.com:myname/oldrep.git
Once you add your origin in git, then you can push your local commit to remote origin
git push -u origin --all
answered Jul 24, 2021 at 22:20
Step:1
git remote rm origin
Step:2
git remote add origin enter_your_repository_url
Example:
git remote add origin https://github.com/my_username/repository_name.git
answered May 6, 2020 at 5:48
if you want to create a new repository with the same project inside the github and the previous Remote is not allowing you to do that in that case First Delete That Repository on github then you simply need to delete the .git folder C:UsersShivaAndroidStudioProjectsyourprojectname.git delete that folder,(make sure you click on hidden file because this folder is hidden )
Also click on the minus(Remove button) from the android studio Setting->VersionControl
click here for removing the Version control from android And then you will be able to create new Repository.
answered Jun 3, 2020 at 13:24
Try this command it works for me.
rm -rf .git/
answered Jun 8, 2022 at 4:39
git remote rm origin
and then
git push -f
answered Mar 24, 2022 at 16:03
RasikhRasikh
111 silver badge2 bronze badges
3
Гитхаб «фатальная ошибка: удаленный происхождения уже существует»
Я пытаюсь следовать вдоль рельсы учебник Майкла Хартла но я столкнулся с ошибкой.
Я зарегистрировался на Github и выдал новый SSH-ключ и создал новый репозиторий. Но когда я ввожу следующую строку в терминал, я получаю следующую ошибку:
Parkers-MacBook-Pro:.ssh ppreyer$ git remote add origin [email protected]:ppreyer/first_app.git
fatal: remote origin already exists.
просто интересно, если кто-нибудь еще столкнулся с этой проблемой?
7618
15
15 ответов:
TL; DR вы должны просто обновить существующий пульт дистанционного управления:
$ git remote set-url origin [email protected]:ppreyer/first_app.git
версия:
как показывает сообщение об ошибке, уже есть удаленный настроенный с тем же именем. Таким образом, вы можете либо добавить новый пульт с другим именем, либо обновить существующий, если он вам не нужен:
чтобы добавить новый пульт дистанционного управления, например
github
вместоorigin
(который, очевидно, уже существует в системе), выполнить следующее:$ git remote add github [email protected]:ppreyer/first_app.git
помните, хотя, везде в учебнике вы видите источник вы должны заменить его с «github». Например
$ git push origin master
теперь должно быть$ git push github master
.однако, если вы хотите увидеть, что это
origin
которая уже существует, вы можете сделать$ git remote -v
. Если вы думаете, что это там по какой-то ошибке, вы можете обновить его так:$ git remote set-url origin [email protected]:ppreyer/first_app.git
Короче,
git remote rm origin git remote add origin [email protected]:username/myapp.git
работала !
Ура!
для тех из вас, кто сталкивается с очень распространенной ошибкой «fatal: remote origin уже существует.», или при попытке удалить origin и вы получаете » ошибка: не удалось удалить раздел конфигурации remote.происхождения», что вам нужно сделать, это установить происхождение вручную.
у окна POSH~Git для Windows PowerShell (и GitHub для приложения Windows) есть проблема с этим.
я столкнулся с этим, как я часто делаю, снова при настройке моего осьминога. Итак, вот как я заставил его работать.
во-первых, проверьте ваши пульты дистанционного управления:
C:gdcodeoctopress [source +2 ~3 -0 !]> git remote -v octopress https://github.com/imathis/octopress.git (fetch) octopress https://github.com/imathis/octopress.git (push) origin
вы сначала заметите, что мой источник не имеет url. Любая попытка удалить его, переименовать и т. д. все терпит неудачу.
Итак, измените url вручную:
git remote set-url --add origin https://github.com/eduncan911/eduncan911.github.io.git
затем вы можете подтвердить, что он работал под управлением
git remote -v
еще раз:C:gdcodeoctopress [source +2 ~3 -0 !]> git remote -v octopress https://github.com/imathis/octopress.git (fetch) octopress https://github.com/imathis/octopress.git (push) origin https://github.com/eduncan911/eduncan911.github.io.git (fetch) origin https://github.com/eduncan911/eduncan911.github.io.git (push)
это исправило десятки репозиториев git, с которыми у меня были проблемы, GitHub, BitBucket GitLab и т. д.
вы можете видеть, к каким удаленным репозиториям вы настроены для подключения через
git remote -v
это вернет список в таком формате:
origin [email protected]:github/git-reference.git (fetch) origin [email protected]:github/git-reference.git (push)
это может помочь вам выяснить, на что указывает оригинальное «происхождение».
если вы хотите сохранить удаленное соединение, которое вы видите с помощью-v, но все же хотите следовать учебнику Rails, не запоминая «github» (или какое-либо другое имя) для РЕПО вашего учебника, вы можете переименовать свой другое репозиторий с помощью команды:
git remote rename [current name] [new name]
в:
git remote rename origin oldrepo
вы должны быть в состоянии возобновить учебник.
сначала сделать:
git remote rm origin
затем
git remote add origin https://github.com/your_user/your_app.git
и вуаля! Работал на меня!
в особом случае, что вы создаете новый репозиторий начиная со старого репозитория, который вы использовали в качестве шаблона (не делайте этого, если это не ваш случай). Полностью удалите файлы git из старого репозитория, чтобы вы могли начать новый:
rm -rf .git
а затем перезапустить новый репозиторий git как обычно:
git init git add whatever.wvr ("git add --all" if you want to add all files) git commit -m "first commit" git remote add origin [email protected]:ppreyer/first_app.git git push -u origin master
Если вам нужно проверить, какие удаленные репозитории вы подключили к вашим локальным репозиториям, есть cmd:
git remote -v
теперь, если вы хотите удалить удаленное РЕПО (скажем, origin) , то вы можете сделать следующее:
git remote rm origin
концепция
remote
— это просто URL вашего удаленного репозитория.The
origin
это псевдоним указывая на этот URL. Поэтому вместо того, чтобы писать весь URL каждый раз, когда мы хотим что-то отправить в наш репозиторий, мы просто используем этот псевдоним и запускаем:
git push -u origin master
говоря, чтобы git to
push
наш код от нашего local мастер филиала до remote происхождения репозиторий.всякий раз, когда мы клонировать репозиторий,git создает псевдоним для нас по умолчанию. Также всякий раз, когда мы создаем новый репозиторий, мы просто создаем его сами.
в любом случае, мы всегда можем изменить это название на все, что нам нравится, работает так:
git remote rename [current-name] [new-name]
так как он хранится на стороне клиента git применение (на нашей машине) изменение его не будет повлиять на что-либо в нашем процессе разработки, ни в нашем удаленном репозитории. Помните, что это только имя указала на адрес.
единственное, что здесь меняется путем переименования псевдонима, это то, что мы должны объявить это новое имя каждый раз, когда мы нажимаем что-то в наше хранилище.
git push -u my-remote-alias master
очевидно, что одно имя не может указывать на два разных адреса. Вот почему вы получаете это сообщение об ошибке. Уже есть псевдоним с именем
origin
на локальной машине. Чтобы узнать, сколько у вас псевдонимов и каковы они, вы можете запустить эту команду:git remote -v
это покажет вам все псевдонимы у вас есть плюс соответствующие URL-адреса.
вы также можете удалить их, если вам нравится запускать это:
git remote rm my-remote-alias
Итак вкратце:
- узнайте, что у вас уже
- удалить или переименовать их,
- добавить новое псевдонимы.
удачи в кодировании.
это сообщение об ошибке указывает на то, что у вас уже есть пульт в вашем каталоге git.
Если вы удовлетворены этим пультом дистанционного управления, вы можете нажать свой код. Если нет или если вы не можете нажать просто:git remote remove origin git remote add origin [email protected]:ppreyer/first_app.git
вуаля !
Это также может произойти, если вы запустите команду в каталоге без инициализации git. Если это так, запустите сначала:
git init
Если вы уже добавляете проект для другого хранилища, например, вы загружаете в github, а затем загружаете в bitbucket, тогда он показывает этот тип ошибки.
Как удалить ошибку: удалите файл Git-hub в вашем проекте, а затем повторите следующие шаги…
git init git remote add origin [email protected]:Yourname/firstdemotry.git git add -A git commit -m 'Message' git push -u origin master
для использования git вы должны быть
root
Если нет, то используйте sudo
для удаления origin:
git remote remove origin
для добавления origin:
git remote add origin http://giturl
$ git remote add origin [email protected]:abc/backend/abc.git
в этой команде origin не является частью команды, это просто имя вашего удаленного репозитория. Вы можете использовать любое имя вы хотите.
- сначала вы можете проверить, что он содержит, используя команду ниже
$ git remote -v
это даст вам такой результат
origin [email protected]:abc/backend/abc.git (fetch)
origin [email protected]:abc/backend/abc.git (push)
origin1 [email protected]:abc/backend/abc.git (fetch)
origin1 [email protected]:abc/backend/abc.git (push)если он содержит путь к удаленному репозиторию, вы можете напрямую нажать на него без добавления происхождение снова
- если он не содержит путь к удаленному репозиторию
затем вы можете добавить новый источник с другим именем и использовать его для нажатия, как
$ git remote add origin101 [email protected]:abc/backend/abc.git
или вы можете переименовать существующее имя источника добавить свой источник
git remote rename origin destination
огонь ниже команды снова
$ git remote -v
destination [email protected]:abc/backend/abc.git (fetch)
destination [email protected]:abc/backend/abc.git (push)он изменит ваше существующее имя репозитория, чтобы вы могли использовать это имя происхождения
или вы можете просто удалить существующий источник и добавить свой источник
git remote rm destination
сначала проверьте, сколько у вас псевдонимов и каковы они, вы можете инициировать эту команду
git remote-vзатем посмотрите, в каком репозитории вы находитесь
тогда попробуй
git удаленного набора-URL-адреса-добавить [ТУТ ВАША ССЫЛКА repositpory ]
git push — U origin master
попробуй такое
- компакт-диск existing_repo
- git remote переименовать origin old-origin
Добавил(а) microsin
Ключевое слово «origin» обычно используется для описания центрального источника (ресурса на сервере) репозитория Git. Если Вы попытаетесь добавить удаленный сервер (remote), так называемый «origin» к репозиторию, в котором описание origin уже существует, то получите ошибку «fatal: remote origin already exists». В этой статье (перевод [1]) мы обсудим подобный случай проблемы «fatal: remote origin already exists» и способ её решения.
Ошибка Git «fatal: remote origin already exists» показывает вам, что Вы пытаетесь создать remote с именем «origin», когда remote с таким именем уже существует (был прописан ранее). Это ошибка — общий случай, когда вы забыли, что уже настроили ссылку на remote репозиторий, и снова выполняете инструкции по установке. Также эту ошибку можно увидеть, если делается попытка поменять URL «origin» remote-репозитория командой git remote add.
Чтобы исправить эту ошибку, нужно сначала проверить, связан ли в настоящий момент remote с ключевым словом «origin», и что у него корректный URL. Вы можете сделать это командой git remote -v:
m:asmradiopager>git remote -v origin https://github.com/microsindotnet/git (fetch) origin https://github.com/microsindotnet/git (push)
Если «origin» URL не соответствует URL Вашего remote-репозитория, к которому Вы хотите обратиться, то можно поменять remote URL. Альтернативно можно удалить remote, и заново установить remote URL с именем «origin».
Пример проблемной ситуации. У нас есть некий репозиторий с именем «git», и мы хотим поменять его текущий origin:
https://github.com/microsindotnet/git
На новый origin:
https://github.com/microsindotnet/gitnew
Чтобы сделать это, мы используем команду git remote add command, который добавляет новый remote к репозиторию:
git remote add origin https://github.com/microsindotnet/gitnew
Но эта команда вернула ошибку:
fatal: remote origin already exists.
Этим сообщением git говорит нам, что remote origin уже существует.
Способ решения проблемы. Мы не можем добавить новый remote, используя имя, которое уже используется, даже если мы указываем для remote новый URL. В этом случае мы попытались создать новый remote с именем «origin», когда remote с таким именем уже существует. Чтобы исправить эту ошибку, мы должны удалить существующий remote, который называется «origin», и добавить новый, либо должны поменять URL существующего remote.
Чтобы удалить существующий remote и добавить новый, мы можем установить новый URL для нашего remote:
git remote set-url origin https://github.com/microsindotnet/gitnew
Это предпочтительный метод, потому что мы можем в одной команде поменять URL, связанный с нашим remote. Не понадобится уделить старый origin и создавать новый, потому что существует команда set-url.
Альтернативно мы можем удалить наш remote «origin», и после этого создать новый, с новым URL:
git remote rm origin git remote add origin https://github.com/microsindotnet/gitnew
Этот метод использует 2 команды вместо одной.
[Ссылки]
1. Git fatal: remote origin already exists Solution site:careerkarma.com.
2. git: быстрый старт.
Adding a remote repository
To add a new remote, use the git remote add
command on the terminal, in the directory your repository is stored at.
The git remote add
command takes two arguments:
- A remote name, for example,
origin
- A remote URL, for example,
https://github.com/user/repo.git
For example:
$ git remote add origin https://github.com/USER/REPO.git
# Set a new remote
$ git remote -v
# Verify new remote
> origin https://github.com/USER/REPO.git (fetch)
> origin https://github.com/USER/REPO.git (push)
For more information on which URL to use, see «About remote repositories.»
Troubleshooting: Remote origin already exists
This error means you’ve tried to add a remote with a name that already exists in your local repository.
$ git remote add origin https://github.com/octocat/Spoon-Knife.git
> fatal: remote origin already exists.
To fix this, you can:
- Use a different name for the new remote.
- Rename the existing remote repository before you add the new remote. For more information, see «Renaming a remote repository» below.
- Delete the existing remote repository before you add the new remote. For more information, see «Removing a remote repository» below.
Changing a remote repository’s URL
The git remote set-url
command changes an existing remote repository URL.
The git remote set-url
command takes two arguments:
- An existing remote name. For example,
origin
orupstream
are two common choices. - A new URL for the remote. For example:
- If you’re updating to use HTTPS, your URL might look like:
https://github.com/USERNAME/REPOSITORY.git
- If you’re updating to use SSH, your URL might look like:
git@github.com:USERNAME/REPOSITORY.git
- If you’re updating to use HTTPS, your URL might look like:
Switching remote URLs from SSH to HTTPS
- Open TerminalTerminalGit Bash.
- Change the current working directory to your local project.
- List your existing remotes in order to get the name of the remote you want to change.
$ git remote -v > origin git@github.com:USERNAME/REPOSITORY.git (fetch) > origin git@github.com:USERNAME/REPOSITORY.git (push)
- Change your remote’s URL from SSH to HTTPS with the
git remote set-url
command.$ git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
- Verify that the remote URL has changed.
$ git remote -v # Verify new remote URL > origin https://github.com/USERNAME/REPOSITORY.git (fetch) > origin https://github.com/USERNAME/REPOSITORY.git (push)
The next time you git fetch
, git pull
, or git push
to the remote repository, you’ll be asked for your GitHub username and password. When Git prompts you for your password, enter your personal access token. Alternatively, you can use a credential helper like Git Credential Manager. Password-based authentication for Git has been removed in favor of more secure authentication methods. For more information, see «Creating a personal access token.»
You can use a credential helper so Git will remember your GitHub username and personal access token every time it talks to GitHub.
Switching remote URLs from HTTPS to SSH
- Open TerminalTerminalGit Bash.
- Change the current working directory to your local project.
- List your existing remotes in order to get the name of the remote you want to change.
$ git remote -v > origin https://github.com/USERNAME/REPOSITORY.git (fetch) > origin https://github.com/USERNAME/REPOSITORY.git (push)
- Change your remote’s URL from HTTPS to SSH with the
git remote set-url
command.$ git remote set-url origin git@github.com:USERNAME/REPOSITORY.git
- Verify that the remote URL has changed.
$ git remote -v # Verify new remote URL > origin git@github.com: USERNAME/REPOSITORY.git (fetch) > origin git@github.com: USERNAME/REPOSITORY.git (push)
Troubleshooting: No such remote ‘[name]’
This error means that the remote you tried to change doesn’t exist:
$ git remote set-url sofake https://github.com/octocat/Spoon-Knife
> fatal: No such remote 'sofake'
Check that you’ve correctly typed the remote name.
Renaming a remote repository
Use the git remote rename
command to rename an existing remote.
The git remote rename
command takes two arguments:
- An existing remote name, for example,
origin
- A new name for the remote, for example,
destination
Example of renaming a remote repository
These examples assume you’re cloning using HTTPS, which is recommended.
$ git remote -v
# View existing remotes
> origin https://github.com/OWNER/REPOSITORY.git (fetch)
> origin https://github.com/OWNER/REPOSITORY.git (push)
$ git remote rename origin destination
# Change remote name from 'origin' to 'destination'
$ git remote -v
# Verify remote's new name
> destination https://github.com/OWNER/REPOSITORY.git (fetch)
> destination https://github.com/OWNER/REPOSITORY.git (push)
Troubleshooting: Could not rename config section ‘remote.[old name]’ to ‘remote.[new name]’
This error means that the old remote name you typed doesn’t exist.
You can check which remotes currently exist with the git remote -v
command:
$ git remote -v
# View existing remotes
> origin https://github.com/OWNER/REPOSITORY.git (fetch)
> origin https://github.com/OWNER/REPOSITORY.git (push)
Troubleshooting: Remote [new name] already exists
This error means that the remote name you want to use already exists. To solve this, either use a different remote name, or rename the original remote.
Removing a remote repository
Use the git remote rm
command to remove a remote URL from your repository.
The git remote rm
command takes one argument:
- A remote name, for example,
destination
Removing the remote URL from your repository only unlinks the local and remote repositories. It does not delete the remote repository.
Example of removing a remote repository
These examples assume you’re cloning using HTTPS, which is recommended.
$ git remote -v
# View current remotes
> origin https://github.com/OWNER/REPOSITORY.git (fetch)
> origin https://github.com/OWNER/REPOSITORY.git (push)
> destination https://github.com/FORKER/REPOSITORY.git (fetch)
> destination https://github.com/FORKER/REPOSITORY.git (push)
$ git remote rm destination
# Remove remote
$ git remote -v
# Verify it's gone
> origin https://github.com/OWNER/REPOSITORY.git (fetch)
> origin https://github.com/OWNER/REPOSITORY.git (push)
Note: git remote rm
does not delete the remote repository from the server. It simply
removes the remote and its references from your local repository.
Troubleshooting: Could not remove config section ‘remote.[name]’
This error means that the remote you tried to delete doesn’t exist:
$ git remote rm sofake
> error: Could not remove config section 'remote.sofake'
Check that you’ve correctly typed the remote name.
Further reading
- «Working with Remotes» from the Pro Git book

This article discusses how to resolve the issue git fatal: remote origin already exists error
during the push or add commands.
Fix git fatal: remote origin already exists error on push
You must run the ‘git init’ command to enable git for any application or folder/directory.
Once git is initialized, we must either create a new repository or clone an existing repository to map this to the existing directory.
if this directory is created in the nested folder of any git repository, the git command throws git fatal: remote origin already exists error.
What does its origin
mean?
This error comes during multiple use cases.
- created a local nested folder app, It is a child folder of a local git repository, these folders map to the new remote repository.
B:blogjswork>git remote add origin https://github.com/intkiran/react-auth0-login.git
fatal: remote origin already exists.
An error would
fatal: remote origin already exists.
From the above code, It creates an origin local name and adds it to an existing repository.
In any local repository, How do you know the remote repository url?
using the -v
option gives the local name with a remote url as described following
And the output is
origin https://github.com/intkiran/react-auth0-login.git (fetch)
origin https://github.com/intkiran/react-auth0-login.git (push)
It gives the remote repository url mapped with the local name i.e origin.
Origin is the local name for the remote repository given by default.
This error occurs after adding a new url to the existing origin.
This post covers the solution for the following errors in the git command
- fatal: No such remote:
- Remote origin already exists on ‘git push’ to a new repository
There are many ways we can fix this.
Remove the original name from the given existing repository
First, delete the local name origin for a given remote repository using the following command.
next, add the original name to the new remote repository
git remote add origin remote-repo-url
set-url Change origin name from the given existing git repository
git remote set-url neworigin remote-repo-url
if remote-repo-url does not exist, it gives an error fatal: No such remote:
.
Replace current origin with new url in Git
below set the new url for the local name origin.
git remote set-url origin remote-repo-url
rename existing origin name in Git
The last approach is to rename the existing origin to the new name
git remote rename origin neworigin
Finally, Verify the name mapped to the URLs using the below command.
wrap
There are many ways we can fix these errors with the above solutions.
What is the ‘fatal: remote origin already exists’ error?
fatal: remote origin already exists
is a common Git error that occurs when you clone a repository from GitHub, or an external remote repository, into your local machine and then try to update the pointing origin
URL to your own repository.
In the context of Kubernetes, the error can occur when you configure orchestrations to include Git repositories. For example, by using: git remote add origin [url].gits
fatal: remote origin already exists
is caused by the cloned repository already having a URL configured. Specifically, a URL that leads to the original profile where the repository source is.
What is a remote origin in Git?
remote origin
, as the name implies, is the place where code is stored remotely. It is the centralized server or zone where everyone pushes code to and pulls code from.
Remote repositories are versions of your project hosted on Git-compatible platforms such as GitHub, Bitbucket, GitLab, and Assembla. origin
is the standard and generic handle that is used to associate the host site’s URL.
For example, you can have an alternative remote
URL called dev
, which then becomes the handle for a separate repository but for the same code.
When you run git remote -v
, you will get a list of handles and associated URLs. So if you have different handlers for the same remote, the console output could look something like this:
D:GitHubgit remote -v origin https://github.com/prod_repo/projectx.git (fetch) origin https://github.com/prod_repo/projectx.git (push) dev https://github.com/dev_repo/projectx.git (fetch) dev https://github.com/dev_repo/projectx.git (push)
This means that you can run the following command: git push dev master
The changes made will get pushed up to the master
branch at the URL associated with dev
and not origin
.
Resolving ‘fatal: remote origin already exists’
For most development environments, origin
is the default handler used. Here are 3 ways to resolve fatal: remote origin already exists
.
1. Remove the Existing Remote
remote
refers to the hosted repository. origin is the pointer to where that remote is. Most of the time, origin
is the only pointer there is on a local repository.
If you want to change the pointing URL attached to origin
, you can remove the existing origin
and then add it back in again with the correct URL.
To remove your handler, use the remove
command on remote
, followed by the handler name – which, in our case, is origin
.
Here is an example: git remote remove origin
To check that handler is deleted properly, run the following: git remote -v
You will either get an empty list, or you will get a list of remote handlers that are currently attached to the project with origin removed from the list.
Now you can run git remote add origin [url].git
without encountering the fatal: remote origin already exists
error.
2. Update the Existing Remote’s URL
You are not always required to remove the origin handler from remote
. An alternative way to solve fatal: remote origin already exists is to update the handler’s pointing URL.
To do this, you can use the set-url
command, followed by the handler name (which is origin in our case) and the new URL.
Here is the syntax for updating an existing origin URL: git remote set-url origin [new-url]
Once this is completed, you can now push and pull code from the newly configured Git repository location.
3. Rename the Existing Remote
Alternatively, you can rename origin
to something else. This means that instead of deleting the handler’s pointing URL to make room for the new one, you can rename it and keep the original details.
To do this, use the rename
command on: remote
.
For example, if you want to rename origin
to dev
, you can use the following command: git remote rename origin dev
Now when you run git remote -v
, you will get dev as the handler instead of origin
.
D:GitHub[some-repo]git remote -v dev https://github.com/some_repo/projectx.git (fetch) dev https://github.com/some_repo/projectx.git (push)
This will give you room to add a new origin
to the list of attached handlers. So when you run git remote add origin [url].git
, you will no longer get the fatal: remote origin already exists
error prompt.
How to prevent ‘fatal: remote origin already exists’
To prevent fatal: remote origin already exists
error from occurring, you can check if the origin
handler already exists. If it does not, running the git add remote origin
command should not produce this issue.
The most important thing to note here is that origin
is only a handler’s short name. It is a reference to the URL, which is where the actual remote repository is hosted.
The handler origin
just happens to be the standardized default. This is what makes fatal: remote origin already exists
so common. The error itself can occur against any handler, provided that it has the same placeholder name.
To check if origin
even exists, run git remote -v
to get a list of current remote handlers and the associated URLs.
If origin exists, you can do one of the following:
- remove
origin
from theremote
list viaremove
command, like so:git remote remove origin
- update origin pointing URL with
set-url
, like so:git remote set-url origin [new-url]
- rename the existing
origin
handler to something else viarename
command:git remote rename origin [new-name]
K8s troubleshooting with Komodor
We hope that the guide above helps you better understand the troubleshooting steps you need to take in order to fix the fatal: remote origin already exists
error.
Keep in mind that this is just one of many Git errors that can pop up in your k8s logs and cause the system to fail. Due to the complex and distributed nature of k8s,
the search for the root cause of each such failure can be stressful, disorienting and time-consuming.
This is why we created Komodor, which acts as a single source of truth (SSOT) to streamline and shorten your k8s troubleshooting processes. Among other features, it offers:
- Change intelligence: Every issue is a result of a change. Within seconds we can help you understand exactly who did what and when.
- In-depth visibility: A complete activity timeline, showing all code and config changes, deployments, alerts, code diffs, pod logs and etc. All within one pane of glass with easy drill-down options.
- Insights into service dependencies: An easy way to understand cross-service changes and visualize their ripple effects across your entire system.
- Seamless notifications: Direct integration with your existing communication channels (e.g., Slack) so you’ll have all the information you need, when you need it.