I want to push the product to a different git URL.

Asked 2 years ago, Updated 2 years ago, 57 views

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.

git

2022-09-29 22:49

3 Answers

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)


2022-09-29 22:49

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.


2022-09-29 22:49

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 .


2022-09-29 22:49

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.