MarvinLeRouge
MarvinLeRouge

Reputation: 534

Renaming a git repository, local and distant

Bitbucket is essentially for me a versioning tool for security reason, no one work on those repos except me. I have a local project, stored in a local directory. The directory was created empty, then i cloned inside a local repository named A from a distant one (on bitbucket).

I work locally, and i commit/push using sourcetree.

I would need to rename a project, which would mean :

Would anyone have a bulletproof method for that ?

N.B. : I'm a git user, which is why i'm using sourcetree, not a git superstar knowing all the commands and options :)

Upvotes: 4

Views: 12953

Answers (1)

LeGEC
LeGEC

Reputation: 51988

A repo doesn't know its name. The only "link" you would have to update is : in your local configuration of remote repositories, you would have to update the url to push to/pull from (which does mention the repo name on bitucket).

Taking back your list of steps :

  • renaming local folder : rename it as you would rename a regular folder ; then open that new folder in Sourcetree

  • renaming local repo : noop

  • renaming distant repo : rename it on bitbucket

  • correct local-distant association in sourcetree :
    thechnically that link is stored in your local repo, in the .git/config file
    you can update it from the command line :

     git remote set-url origin https://bitbucket.org/url/to/newname
    

    Sourcetree probably has a settings screen where you can apply the same action ; this setting is obviously a per repo setting, do not look for it in some "global settings" or "global preferences" section.

Run a simple git fetch to check that the url is correctly registered.

Upvotes: 13

Related Questions