开发者

If I have a GIT repo (bare) on my server, can I move it to another server easily?

开发者 https://www.devze.com 2023-01-08 05:03 出处:网络
I have a server that is hosting my \'bare\' GIT repo for a few projects. I want to know what it takes to move the GIT to anot开发者_运维技巧her server?Just copy the parent directory to the new machin

I have a server that is hosting my 'bare' GIT repo for a few projects.

I want to know what it takes to move the GIT to anot开发者_运维技巧her server?


Just copy the parent directory to the new machine and have the checked out copies update their remote with git remote set-url <remotename> <url>. Once you've verified that the users can push/pull properly with the new remote you can delete the copy from the old machine.


Doesn't this work?

  • clone it locally
  • create a new empty bare repo in the other server
  • then push the clone.


Git repositories are location-agnostic as to their host file system, and Git itself does not depend on a persistent server process – so on the server side, all you need to do is just copy the foo.git directory to somewhere on your new server.

And all remotes are equal in Git. So you can just add the new URL as another remote if you want to. Or else you can just open the .git/config file and edit the URL of your existing remote to change it. (If it doesn’t work, you can change it back in the same way.)

Git is very non-magic.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号