I recently renamed a remote to a new alias and the old alias (and all its commits up until the point of renaming) is still visible in the logs and consequently gitk. Running
$ git remote show old-alias
obviously returns:
fatal: 'old-alias' does not appear to be a git repository
This is pretty annoying. How do I cleanly remove these references? Is it OK if I manually delete the
.git/logs/refs/remotes/old-alias/
.git/refs/remotes/old-alias/
directories?
Edit:
Here is the git remote -v
output:
origin git@github.com:my-user/our-repo (fetch)
origin git@github.com:my-user/our-repo (push)
upstream git@github.com:upstream-user/our-repo (fetch)
upstream git@github.com:upstream-user/our-repo (push)
Here is the git log --oneline --graph --decorate
output:
* 692d53f (HEAD, origin/somebranch, somebranch) Commit message
* 9a4e794 Commit message
* 419376b Commit message
* 9a945bd (origin/someotherbranch, someotherbranch) Commit message
* 9a0fe3b Commit message
* 021d553 Commit message
* fa60dba Commit message
* 2d52d72 Commit message
* c59307f Commit message
* b89ae1c Commit message
* 063030c Commit message
* 97b8c77 Commit message
* ec65002 Commit message
* 38d7bb8 Commit message
* 36856fc Commit message
* 13b5065 Commit message
* 66e7dae (upstream/master, origin/master, old-alias/master, master) Commit message
|\
| * caf7e86 Commit message
| * a0c5abe Commit message
| * 9d1a735 Commit message
| * 4e7770d Commit message
| * cd3dd89 Commit message
* | 3037432 Merge pull request message
|\ \
| |/
| * 12b4a01 Commit message
| * be41159 Commit message
|/
* 8210859 Commit message
* 6b2090e Commit message
* 4b069f3 Commit message
* 1ef939c Merge pull request message
|\
| * fc559bb Commit message
|/
* 6fab424 Commit message
* ce10b38 Commit message
* 345128e Commit message
old-alias
was changed to origin
around commit 2d52d72
via git remote rename old-alias origin
.
The question here has a similar issue: Why is old name of git remote sill in .git/refs/remotes?. Following the advice there, I deleted the
.git/logs/refs/remotes/old-alias/
.git/refs/remotes/old-alias/
directories manually. There are residual logs in .git/logs/HEAD
and .git/logs/refs/heads/someotherbranch
:
./logs/HEAD:14:6d8019... Ayberk Özgür <ayberk.ozgur@email.com> 1394819391 +0100 pull old-alias someotherbranch: Fast-forward
./logs/refs/heads/android:13:6d8019... Ayberk Özgür <ayberk.ozgur@email.com> 1394819391 +0100 pull old-alias someotherbranch: Fast-forward
I don't exactly know if those are the only traces left of old-alias
or whether they may be harmful. However, I haven't encountered any issues so far.