Home > OS >  Which are the side effects of renaming a Git repository
Which are the side effects of renaming a Git repository

Time:11-10

Say I need to rename a Git repository that has already been downloaded by a number of developers.

If I rename this repository, what side effects would happen, if any? I mean besides the developers having to perform a change in their local repository to change its remote repository like this

git remote set-url origin new_url

For the sake of the argument please consider that the Git server is a private one and all the developers form part of the same company.

For what it's worth, I have checked other questions regarding renaming repositories in Git, but none of them speak specifically about side effects except for the git remote change.

How does renaming a Bitbucket git repository affect forked repositories?

How do I rename a Git repository?

How do I rename a repository on GitHub?

CodePudding user response:

As I said in a comment four days ago, the only real "side effect" of changing a name is that everyone use uses the name has to change their use as well. That's not exactly a side effect, since it's the main effect: you've changed the name!

The more interesting question is therefore: Who uses this name? Some of the answers here are obvious: it's stored in various URLs, typically under various "remotes" like origin:

$ git config --get remote.origin.url
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/

(this clone predates the public-access ones on GitHub, such as https://github.com/torvalds/linux, or I'd probably use that one). If Linus Torvalds were to rename his Git repository here, I'd have to change the stored URL. But you already called this out yourself.

So: where else might the name of the repository get stored? The only other places I can think of are:

  • in various shell scripts and YAML files and so on that, for whatever reason, them stored in them; and
  • in --shared and/or --reference clones, which set up what Git calls alternates within a repository.

If you have made such clones, you should check for this. It might be nice if Git had a more convenient way to do it, but basically the existing way to do it is to find all your .git directories and check for objects/info/alternates in them. See also What are the differences between git clone --shared and --reference?

Shell scripts, YAML files, and so forth have many forms and there's no universal way to find them all, though the obvious "grep" style check is obvious. (It could still miss any that got converted to binary with and/or compressed.)

  • Related