git About Remote Storage

Asked 2 years ago, Updated 2 years ago, 60 views

To change the git remote repository that I saved while working on it, On Terminal

git remote set-urlorigin New remote storage address.git Enter to change the remote repository and then

I tried to push by entering git push-u origin master When the message rejected came up, a hint came out like the attached image file

git to change remote repository Does git remote set-urlorigin need to go through a process other than the instruction statement? (For example, you have to disconnect the existing git remote repository.))

How can I change git remote repository?

git github

2022-09-22 21:50

3 Answers

This message is caused by a difference between a local repository and a remote repository.

After importing the contents of the remote repository into the local repository with pull, you must: If a conflict occurs during this process, you must do merge that combines the contents of the remote and local storage. There is also a force push that forcibly overwrites the contents of the remote repository with the contents of the local repository, but merge is recommended. Merging on the terminal is not easy. In this case, it is convenient to use tools such as GitKraken.

You can also change the storage in the following ways.

Use git remote -v to determine the current repository and shortcut name.

git remote set-url Short name (for example, origin) Repository (for example, https://xx)

or git remote remove Short name -> git remote add Short name New storage


2022-09-22 21:50

The current status of the local branch and the changed status of the storage branch are different I think I need to push again after I pull and merge. Or, if you can forcefully change the local state to the remote state, you can force pull it.


2022-09-22 21:50

Open the storage information yourself and see where [remote "origin"" is located.

.git/config

Clear that part and try again from git remote set-urlorigin new address.


2022-09-22 21:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.