Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Change "origin" of your GIT repository
$ git remote rm origin
$ git remote add origin git@github.com:aplikacjainfo/proj1.git
$ git config master.remote origin
$ git config master.merge refs/heads/master
@LucEnden
Copy link

LucEnden commented Jan 2, 2021

+1 Thanks, this is amazing!

@alipirzada1
Copy link

alipirzada1 commented Jan 23, 2021

+1 thanks, it was really helpful. thanks!!!

@TharukaNG
Copy link

TharukaNG commented Feb 7, 2021

+1 Thank you so much

@nald-dev
Copy link

nald-dev commented Feb 11, 2021

+1 thanks for git remote rm origin

@thomstrub
Copy link

thomstrub commented Mar 3, 2021

+1 thanks!

@bcyoungV
Copy link

bcyoungV commented Mar 6, 2021

Thanks!

@helenabjalkovska
Copy link

helenabjalkovska commented Mar 11, 2021

+1

@jayanath
Copy link

jayanath commented Mar 30, 2021

Thank you! 🚀 🌟

@Marianbc
Copy link

Marianbc commented Apr 13, 2021

simple and sweet. +1

@rivka567
Copy link

rivka567 commented Apr 14, 2021

Thank you!!!!!!!

@cloudFitly
Copy link

cloudFitly commented Apr 17, 2021

gracias

@luispablo
Copy link

luispablo commented Apr 21, 2021

+1

@AdvaithD
Copy link

AdvaithD commented Apr 23, 2021

clutch szn

@donbr
Copy link

donbr commented May 15, 2021

thanks!

@blumanio
Copy link

blumanio commented Jun 9, 2021

+1

@Chloeem
Copy link

Chloeem commented Jul 31, 2021

thanks for this!

@rilwansmith
Copy link

rilwansmith commented Aug 18, 2021

Can someone explain what each of the commands do?
Thanks.

@ghostdevv
Copy link

ghostdevv commented Aug 28, 2021

Wouldn't git remove set-url origin <url> be shorter?

@AlexaderLex
Copy link

AlexaderLex commented Sep 1, 2021

Thank you! Thank you! Thank you!!!

@balupton
Copy link

balupton commented Sep 1, 2021

Wouldn't git remove set-url origin <url> be shorter?

it would be if it worked, however it rarely works for all sorts of reasons (push and fetch urls being different, different branches having different remotes, multiple urls for a single remote)

@ghostdevv
Copy link

ghostdevv commented Sep 1, 2021

@bal

Wouldn't git remove set-url origin <url> be shorter?

it would be if it worked, however it rarely works for all sorts of reasons (push and fetch urls being different, different branches having different remotes, multiple urls for a single remote)

Makes sense!

@atattibayev
Copy link

atattibayev commented Sep 18, 2021

Thank you so much! It worked for me as well!

@lung21
Copy link

lung21 commented Oct 5, 2021

Thank you for the hint

@jesscarlos
Copy link

jesscarlos commented Oct 13, 2021

Wouldn't git remove set-url origin <url> be shorter?

it would be if it worked, however it rarely works for all sorts of reasons (push and fetch urls being different, different branches having different remotes, multiple urls for a single remote)

I think you mean git remote set-url origin <url>

@RenatoLopes771
Copy link

RenatoLopes771 commented Oct 28, 2021

+1

what are the last 2 commands for though?

@PrernaWeb
Copy link

PrernaWeb commented Oct 28, 2021

I left off the last 2 commands, still worked.

@DLesmes
Copy link

DLesmes commented Nov 19, 2021

3 years later, thnx x 1k

@cgrant417
Copy link

cgrant417 commented Nov 29, 2021

After doing this, github desktop wants me to publish the local copy!?!
If I use
$ git remote set-url origin <remote_url>
I don't run into this problem. They are properly synced.

@Liran-tal
Copy link

Liran-tal commented Dec 22, 2021

Thank you. As a noob, it is very helpful to see the simple way things get done.

@mclements
Copy link

mclements commented Apr 13, 2022

After GitHub changed the default branch name from master to main, I used:

$ git remote rm origin
$ git remote add origin git@github.com:aplikacjainfo/proj1.git
$ git config main.remote origin
$ git config main.merge refs/heads/main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment