How to redirect your repo to another remote in git
You have a local repository. Let's say you cloned this repo from a remote source, but now you forked it somewhere else and you want to push a commit or two to the forked one. How can you do that?
First of all, verify your remotes:
git remote -v
You should see something like this:
origin https://github.com/exoticorn/exoquant-rs (fetch)
origin https://github.com/exoticorn/exoquant-rs (push)
origin
is the shortcut-name that we give to the URL on the right side, so it's the default remote repository. How can we change it? Really simple:
git remote set-url origin <new-remote-url>
If the URL of the forked repo is this one `https://github.com/gicrisf/exoquant-rs`, you should pass it to the command like this:
git remote set-url origin https://github.com/gicrisf/exoquant-rs
Very good! Now, you could launch `git remote -v` again and see the changes:
origin https://github.com/gicrisf/exoquant-rs (fetch)
origin https://github.com/gicrisf/exoquant-rs (push)
Well done, now you can push every change you want on your own fork without messing with the code of anybody else.
Did you find this post useful?
Remember that this website doesn’t make use of any trackers or analytics or adv so it doesn’t earn from your visits (moreover, it has a minimal environmental impact).
If you like this blog, refill my caffeine supplies by