8

I run a git server which contains only the bare remotes. Say, I have one bare remote called DIG.git which I usually clone with:

git clone 55.66.77.88:git/DIG.git

and I want to rename the bare remote on the server from DIG.git to DIGit so that I can do

git clone 55.66.77.88:git/DIGit

Can I just log into the server and do

mv DIG.git DIGit

or is this considered bad practice? If so what is the right way to rename a bare remote?

lord.garbage
  • 5,884
  • 5
  • 36
  • 55

1 Answers1

11

You can rename the top folder of a git repo (bare or not) anyway you want.

It simply is the naming convention to have a .git extension to that folder when it is a bare repo, but this isn't mandatory.

Once you have renamed the repo on the server, you would have to change its origin url on the local clone that you did before:

cd /path/to/local/clone
git remote set-url origin 55.66.77.88:git/DIGit
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks! Can this also be done locally, i.e. I only use `git` commands that rename the remote bare repo and change the url accordingly. This e.g. would be interesting for servers were I have full control over the bare remote but cannot login to the server. – lord.garbage Apr 09 '15 at 11:45
  • 1
    @brauner you can rename a repo locally, but you would still have to keep the same URL for origin, as you cannot rename a remote repo from the local workstation: you would need to have access to the server (or have an ACL system like gitolite installed on the server) – VonC Apr 09 '15 at 11:49
  • @brauner with gitolite, that would be http://gitolite.com/gitolite/gitolite.html#cb-commands, implementing the rename as described in http://stackoverflow.com/a/5164868/6309 – VonC Apr 09 '15 at 11:56
  • @LéaMassiot `a:/.git/`? Is that a local path? – VonC Jun 30 '17 at 13:17
  • @VonC ### In a Windows environment, consider two machines A and B on a LAN. On B, the directory containing the .git directory is a share. On A, we map the network drive a: onto this .git directory. I am just mentionning this because quasi all git commands examples are given with a URL... So, yes we can say it's a local path... – Léa Massiot Jul 01 '17 at 14:22
  • @LéaMassiot Right! The local protocol (https://git-scm.com/book/id/v2/Git-on-the-Server-The-Protocols#_local_protocol), meaning file:///a/.git (which, incidentally, ... is an URL!) – VonC Jul 01 '17 at 15:00