Friday, 26 July 2013

Migration Of Git Repo From One Server To Another

Linux distribution like Debian. First, you create a 'git' user. 

$ adduser git $ su git $ cd


Now, you can set up an empty repository for them by running git init with the --bare option, which initializes the repository without a working directory:
$ cd /home/git
$ mkdir project.git
$ cd project.git
$ git --bare init

Here is how to move your GIT repository from one server to another. In my case I needed to move from Old-server to a New-server.


On New-server : 

$ mkdir tempgit
$ cd tempgit
$ git clone --bare git@Old_Git_Server:Old-Repo.git
$ cd Old-Repo.git
$ git push --mirror git@New_Git_Server:New-Repo.git
$ cd ..
$ rm -rf {REPOSITORY_NAME}.git

On Client Side: 

$ git clone git@:New_Git_Server:New-Repo.git
$ cd project
$ vim README
$ git commit -am 'fix for the README file'
$ git push origin master









No comments:

Post a Comment