remove - git show remote url
How to change the URI(URL) for a remote Git repository? (8)
I have a repo (origin) on a USB key that I cloned on my hard drive (local). I moved "origin" to a NAS and successfully tested cloning it from here.
I would like to know if I can change the URI of "origin" in the settings of "local" so it will now pull from the NAS, and not from the USB key.
For now, I can see two solutions:
push everything to the usb-orign, and copy it to the NAS again (implies a lot of work due to new commits to nas-origin);
add a new remote to "local" and delete the old one (I fear I'll break my history).
Switching remote URLs
Ist Step:- Change the current working directory to your local project.
2nd Step:- 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 [email protected]:USERNAME/REPOSITORY.git
Now Verify that the remote URL has changed.
git remote -v
Verify new remote URL
origin [email protected]:USERNAME/REPOSITORY.git (fetch) origin [email protected]:USERNAME/REPOSITORY.git (push)
- remove origin using command on gitbash git remote rm origin
- And now add new Origin using gitbash git remote add origin (Copy HTTP URL from your project repository in bit bucket) done
You may encounter these errors when trying to changing a remote. 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.
git remote set-url origin <project>
In the Git Bash, enter the command:
git remote set-url origin https://NewRepoLink.git
Enter the Credentials
git remote set-url origin git://new.url.here
git help remote) or you can just edit
.git/config and change the URLs there. You're not in any danger of losing history unless you do something very silly (and if you're worried, just make a copy of your repo, since your repo is your history.)
if you cloned your local will automatically consist,
remote URL where it gets cloned.
you can check it using
git remote -v
if you want to made change in it,
git remote set-url origin https://github.io/my_repo.git
origin - your branch
if you want to overwrite existing branch you can still use it.. it will override your existing ... it will do,
git remote remove url and git remote add origin url
git remote -v # View existing remotes # origin https://github.com/user/repo.git (fetch) # origin https://github.com/user/repo.git (push) git remote set-url origin https://github.com/user/repo2.git # Change the 'origin' remote's URL git remote -v # Verify new remote URL # origin https://github.com/user/repo2.git (fetch) # origin https://github.com/user/repo2.git (push)