So . . . Your Git Repo Moved

Sometimes “they” move the location of your git repository.  Seems to be happening a lot in my last few years of coding.

There are a few ways to deal with this moving, but it is important to remember that git is very, very good at a move situation since every commit is unique and it’s distributed nature lends itself to using different locations.

The DevOps team sent out instructions for us to deal with change, including “check everything in, make sure you are up to date” etc.  Prudent but not necessary.  They sent a command line method out for the change and even renamed the repository for some reason.

(That rename did not need to be done for our use case, but certainly you could. Although, since they did change our repo name *and* we are all still located in on our original local directory “oldreponame”  I am not sure what will eventually play out. Niiiice.)

Well here were their marching orders:

git remote set-url origin https://<username>@bitbucket.org/newrepolocation/newreponame.git
git remote set-url –push origin https://<username>@bitbucket.org/newrepolocation/newreponame.git

Always good to know git command line stuff, no doubt.

Myself? Well I’m a ragtime guy. I just opened up /.git/config and changed this entry:

[remote “origin”]
url = https://<username>@bitbucket.org/oldrepolocation/oldreponame.git
fetch = +refs/heads/*:refs/remotes/origin/*

to this:

[remote “origin”]
url = https://<username>@bitbucket.org/newrepolocation/newreponame.git
fetch = +refs/heads/*:refs/remotes/origin/*

Badabingo.

I didn’t tell DevOps though.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>