Hmm.
It’s quite strange as to why your origin doesn’t have a value. Typically, it should look like this:
[mayur.n@harry_potter]$ git remote -v
origin /mnt/temp.git (fetch)
origin /mnt/temp.git (push)
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».
Now what can you do ?
Try this:
1) Clone the repository in another directory.
2) run «git remote -v
» and get the value of origin
3) In your case it looks like the value is «https://github.com/LongKnight/git-basics.git»
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
«
7) Check what’s the value of origin now with «git remote -v»
It should be correctly set now. If so, run «
git push
»
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
25.7k19 gold badges49 silver badges81 bronze badges
asked Aug 3, 2009 at 11:32
uzumaki narutouzumaki naruto
6,9793 gold badges18 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,4132 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
8,0772 gold badges69 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
310k65 gold badges218 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:\path\to\old\repository
. - 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,6582 gold badges25 silver badges41 bronze badges
answered Jan 23, 2014 at 13:28
MichaelMichael
3,9824 gold badges31 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
78710 silver badges14 bronze badges
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
4,59214 gold badges29 silver badges50 bronze badges
answered Feb 1, 2022 at 20:07
Mansi ShahMansi Shah
2372 silver badges6 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
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,9312 gold badges18 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
4,0411 gold badge17 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
25.1k11 gold badges113 silver badges117 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
This can also happen when you forget to make a first commit.
answered Jun 23, 2017 at 3:39
Clay MortonClay Morton
3332 silver badges15 bronze badges
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
9592 gold badges9 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
Pramod LawatePramod Lawate
6451 gold badge7 silver badges21 bronze badges
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:\Users\Shiva\AndroidStudioProjects\yourprojectname\.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
1
git remote rm origin
and then
git push -f
answered Mar 24, 2022 at 16:03
RasikhRasikh
51 silver badge2 bronze badges
3
I’m not sure if it would necessarily be a bug. On one hand, I would say that it is behaving exactly as it is currently set up to. On the other hand, the way it’s currently set up does block a potential workflow that I believe it should probably be supporting. To that end it feels like more of an enhancement.
I looked into further earlier today. There’s a couple things to consider.
- We could go back and make it so that although it will remove the
DestinationExistsError
as it currently does (when the destination path is still it’s initial value and no clone url is entered/selected) but not re-validate the path on focus.
If this is done, then if a user enters a destination path that is not an existing folder, but then creates the folder at the path (empty or not), there will be no red banner notification to let them know that it already exists. If it’s empty, it would let them clone. However, if it has files, an pop-up error will show up. fatal: destination path '[USER PATH]' already exists and is not an empty directory.
Though, the issue as it has been reported would still occur in situations like clicking the destination path input (or typing in it) after creating a folder outside of Desktop. This would cause it to re-validate, and since the validation function has not changed it would generate the error like what has been reported.
- We could update the validation function to check if a folder is empty, and if it is, accept it as okay for cloning.
This would allow to warn the user via the red banner error display when a folder containing files exists at the path while eliminating both situations where an error could display for an empty folder being selected.
The first option is simpler but still leaves a scenario with this issue (effectively behaving as it did before my change). The second option should cover each scenario, however I did have one concern. I have already tried and tested a solution for this and it seems to work as intended. However, to do so, I make use of fs.readDir
, which retrieves a list of file names in the folder. This allows checking if the folder is empty or not, but may be less efficient for folders with a lot of files, as a repository folder very well may.
Perhaps someone knows a more efficient way to check this though. I could make a pull request for this solution and figure out if there are improvements that can be made during the review of it.
The most common way to clone git repository is to enter in the terminal command that
looks like something like this:
git clone https://github.com/bessarabov/my_project.git
This command will create the directory «my_project» in the current directory and it will clone
repo to that directory. Here is an example:
$ pwd
/Users/bessarabov
$ git clone https://github.com/bessarabov/my_project.git
Cloning into 'my_project'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
$ ls -1a my_project/
.
..
.git
README.md
$
Command «pwd» prints the directory where you are now. The command «git clone …» does the clone.
And with «ls» command we check that there is a hidden «.git» directory that stores all the history
and other meta information and there is a «README.md» file.
Specify directory to clone to
Sometimes you need to place git repository in some other directory. Here is an example:
$ pwd
/Users/bessarabov
$ git clone https://github.com/bessarabov/my_project.git project
Cloning into 'project'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
$ ls -1a project
.
..
.git
README.md
$
As you can see here I used «git clone» command with two parameters:
- the first paramter is the url to the repo
- the second paramter is the directory where to clone repo
Clone to the current directory
And sometimes you need to clone the git repo to the current directory. To specify
the current directory the symbol dot is used. So to clone repo to the current
directory you need to specify two parameters to git clone:
- the url of the repo
- just one symbol — dot — «.» — it means current directory
Here is an example:
$ mkdir the_project
$ cd the_project/
$ pwd
/Users/bessarabov/the_project
git clone https://github.com/bessarabov/my_project.git .
Cloning into '.'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
$ ls -1a
.
..
.git
README.md
$
Here I have created a new directory with the name «the_project», then I’ve entered it
with «cd» command and did the clone with the command «git clone url .». The dot in
this command is what makes git clone to the directory where I’m now.
Error «fatal: destination path ‘.’ already exists and is not an empty directory»
Sometimes you can see error message:
$ git clone https://github.com/bessarabov/my_project.git .
fatal: destination path '.' already exists and is not an empty directory.
It means exactly what it it written in this message. You are trying to checkout
repo to the directory that has some files in it. With the command «ls» you can check
what files are in the current directory. It is also possible that there are some
hidden files, so it is better to use «-a» option to make «ls» show all files
including hidden:
$ ls -1a
.
..
.git
README.md
The «ls» command shows that git is right. The directory is not empty. There is a
directory .git and a file README.md. You can permanent delete that files with
the command «rm» (but do it only if you don’t need those files, you will not
be able to «undelete» them):
$ rm -rf .git README.md
After that the «git clone» will succeed:
$ git clone https://github.com/bessarabov/my_project.git .
Cloning into '.'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
$
Recap
- When you use «git clone url» the directory will be automatically created
- You can specify what directory to create with the command «git clone url dir»
- If you need to clone to the current directory you need to run command «git clone url .»
Путь назначения уже существует и не является пустым каталогом
Я клонировал репозиторий git, но случайно напортачил. Итак, я повторно клонировал, и появилось сообщение:
destination path already exists and is not an empty directory
Я попытался удалить папки на моем Mac с именем пути назначения, но это не сработало.
Я новичок в программировании, поэтому вся помощь будет признательна.
Ответы
10
Это просто означает, что клон git скопировал файлы с github и поместил их в папку. Если вы попытаетесь сделать это снова, это не позволит вам, потому что он не может клонировать в папку, в которой есть файлы. Поэтому, если вы считаете, что клон git завершился некорректно, просто удалите папку и снова выполните клон git. Клон создает папку с тем же именем, что и репозиторий git.
Если у вас есть Destination path XXX already exists, это означает, что имя репозитория проекта, который вы пытаетесь клонировать, уже существует в этом текущем каталоге. Поэтому, пожалуйста, проверьте и удалите любой существующий и попробуйте клонировать его снова.
Объяснение
Это довольно расплывчато, но я сделаю все возможное, чтобы помочь.
Во-первых, хотя поначалу это может показаться пугающим, я предлагаю вам научиться делать что-то из командной строки (называемой терминалом в OSX). Это отличный способ убедиться, что вы размещаете вещи там, где действительно хотите.
Вам обязательно нужно погуглить «команды unix», чтобы узнать больше, но вот несколько важных команд, которые помогут в этой ситуации:
Ls — список всех файлов и каталогов (папок) в текущем каталоге
Cd <input directory here without these brackets> — смените каталог или смените папку, в которой вы смотрите
Mkdir <input directory name without brackets> — создает новый каталог (будьте осторожны, вам нужно будет войти в каталог после того, как вы его создадите)
Rm -r <input directory name without brackets> — Удаляет каталог и все, что в нем
Git clone <link to repo without brackets> — клонирует репозиторий в каталог, который вы просматриваете в данный момент.
Отвечать
Итак, на своем компьютере я бы запустил следующие команды, чтобы создать каталог (папку) с именем проекты в моей папке документов и клонировать там репо.
- Открытый терминал
cd documents
(без учета регистра на Mac)mkdir projects
cd projects
git clone https://github.com/seanbecker15/wherecanifindit.git
cd wherecanifindit
(если я хочу зайти в каталог)
P.s. wherecanifindit — это просто имя моего репозитория git, а не команда!
Спроектированный способ решить эту проблему, если у вас уже есть файлы, которые нужно отправить на Github / Server:
-
В Github / Server, где будет жить ваше репо:
- Создать пустой репозиторий Git (сохранить
<YourPathAndRepoName>
) $git init --bare
- Создать пустой репозиторий Git (сохранить
-
Локальный компьютер (Просто положи в любую папку):
$touch .gitignore
- (Добавьте файлы, которые вы хотите игнорировать в текстовом редакторе, в .gitignore)
-
$git clone <YourPathAndRepoName>
-
(Это создаст пустую папку с вашим именем репо из Github / Server)
-
(Законно скопируйте и вставьте все свои файлы откуда угодно и вставьте их в это пустое репо)
$git push origin master
У меня такая же проблема при использовании Cygwin для установки NVM
Фактически, целевой каталог был пустым, но использовался двоичный файл git из Windows (а не git из cygwin git package).
После установки cygwin git package, установка git clone из nvm прошла нормально!
Что мне нравится, так это то, что я создал новую папку, в которой нет других файлов,
и выбрал эту новую папку, которую я создал, и поместил туда клон.
Надеюсь, это поможет
Шаги, чтобы получить эту ошибку;
- Клонировать репо (например, взять имя как xyz) в папку
- Не пытайтесь повторить клонирование в той же папке. Эта ошибка возникнет даже после удаления папки вручную, поскольку удаление папки не приводит к удалению git info.
Решение :
rm -rf «имя папки репо, в нашем случае xyz». Так
rm -rf xyz
Эта ошибка возникает, когда вы пытаетесь клонировать репозиторий в папку, которая все еще содержит папку .git (Скрытая папка).
Если предыдущие ответы не помогли, вы можете перейти к моему ответу. Надеюсь, это решит вашу проблему.
Откройте терминал и измените каталог на папку назначения (куда вы хотите клонировать).
Теперь введите: ls -a
Вы можете увидеть папку с именем .git.
Вы должны удалить эту папку с помощью следующей команды: rm -rf .git
Теперь вы готовы клонировать свой проект.
Создайте новый каталог, а затем используйте URL-адрес git clone
Используйте команду: ls -a
Вы увидите список файлов или папок, которые его блокируют.
Используйте команду: rm -r Имя папки / имя файла
После удаления всех файлов и папок. Вы можете клонировать свой проект в каталог
Другие вопросы по теме
Hmm.
It’s quite strange as to why your origin doesn’t have a value. Typically, it should look like this:
[mayur.n@harry_potter]$ git remote -v
origin /mnt/temp.git (fetch)
origin /mnt/temp.git (push)
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».
Now what can you do ?
Try this:
1) Clone the repository in another directory.
2) run «git remote -v
» and get the value of origin
3) In your case it looks like the value is «https://github.com/LongKnight/git-basics.git»
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
«
7) Check what’s the value of origin now with «git remote -v»
It should be correctly set now. If so, run «
git push
»
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
25.7k19 gold badges49 silver badges81 bronze badges
asked Aug 3, 2009 at 11:32
uzumaki narutouzumaki naruto
6,9793 gold badges18 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,4132 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
8,0772 gold badges69 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
310k65 gold badges218 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:\path\to\old\repository
. - 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,6582 gold badges25 silver badges41 bronze badges
answered Jan 23, 2014 at 13:28
MichaelMichael
3,9824 gold badges31 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
78710 silver badges14 bronze badges
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
4,59214 gold badges29 silver badges50 bronze badges
answered Feb 1, 2022 at 20:07
Mansi ShahMansi Shah
2372 silver badges6 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
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,9312 gold badges18 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
4,0411 gold badge17 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
25.1k11 gold badges113 silver badges117 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
This can also happen when you forget to make a first commit.
answered Jun 23, 2017 at 3:39
Clay MortonClay Morton
3332 silver badges15 bronze badges
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
9592 gold badges9 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
Pramod LawatePramod Lawate
6451 gold badge7 silver badges21 bronze badges
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:\Users\Shiva\AndroidStudioProjects\yourprojectname\.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
1
git remote rm origin
and then
git push -f
answered Mar 24, 2022 at 16:03
RasikhRasikh
51 silver badge2 bronze badges
3