I have an old repo server at server1.example.com
and I want to transfer all git repositories to git.example.com
. Does git support configuring server1.example.com
so that in case anybody still tries to fetch
, push
or clone
their workspace against server1.example.com
, they would get a custom error message saying "error: server1.example.com has been shut down, use git.example.com instead
"?
Asked
Active
Viewed 56 times
0

Mikko Rantalainen
- 14,132
- 10
- 74
- 112
1 Answers
2
You can use a simple git hook: Hooks are scripts that are executed in certain circumstances. You can set up a server-side pre-receive hook, running always when someone tries to push to your repository, that always exits with exit code 1 (and thus will decline every push) and shows the error: server1.example.com has been shut down, use git.example.com instead
message.
An example (that is probably too sophisticated for your case) can be found here.
This will only work for pushes, however. The possibility of something like clone
hooks is discussed here, for fetch
here, but there is no git internal funktionality for either one.

kowsky
- 12,647
- 2
- 28
- 41