I would like to push the product to a different git URL.
If you type ~/Downloads/app/git remote add origin https://github.com/myname/app_comp.git, you can use the
fatal:remote origin already exists.
I downloaded the product from a different URL from gitclonehttps://github.com/myname/app.git, so I thought that address was set, but how can I push it to the https://github.com/myname/app_comp.git address?It's not like I'm switching branches.
If the previously cloned myname/app.git
is already registered as origin
, the remote repository of the different git = myname/app_comp.git
must be registered as alias.
This example shows how to add a remote repository as mirror
instead of origin
.
$git remote add mirror https://github.com/myname/app_comp.git
Alternatively, renaming the existing origin
as another name and re-register myname/app_comp.git
as origin
.
If you have registered more than one remote repository, you can see the following in git remote
:
$git remote-v
origin https://github.com/myname/app.git (fetch)
origin https://github.com/myname/app.git (push)
mirror https://github.com/myname/app_comp.git (fetch)
mirror https://github.com/myname/app_comp.git (push)
The title is "I want to push the product to a different git URL", so it is possible to simply use the following method.
*I don't know what branch I'm trying to push, so I'll say master.
git push https://github.com/myname/app_comp.git master
as stated in the question or in another person's answer.
origin
is registered as an alias for https://github.com/myname/app.git
.
The git push
command specifies the remote repository to be pushed to as follows:
git push<remote repository><branch/commit hash>to push;
So if you want to register https://github.com/myname/app_comp.git
as mirror
,
git push mirror master
You must run the command as shown in .
<PushBranch/Commit Hash>
is optional, but I personally prefer not to omit it because I think it is better to be aware of what changes you are trying to push to Where.
If you want origin to be a different URL,
git remote set-url origin https://github.com/myname/app_comp.git
It is rewritten in .After that,
git remote-v
You can see that the origin URL has been rewritten in .
© 2024 OneMinuteCode. All rights reserved.