Home > Umum > Moving git repository to new server

Moving git repository to new server

1. Fetch all of the remote branches and tags from the existing repository to our local index

git fetch origin

2. Check all branch

git branch -a

01
3. Add new ssh config for new server. Create new file with text editor, I use notepad++, name with config. For windows save in C:\Users\sashihara\.ssh. After this you will have 3 file, config, id_rsa, id_rsa_aws.

Host host1 ip_host1
 HostName ip_host1
 IdentityFile C:\Users\sashihara\.ssh\id_rsa
 User gituser

Host host2 ip_host2
 HostName ip_host2
 IdentityFile C:\Users\sashihara\.ssh\id_rsa_aws
 User gituser

4. Add new remote origin, give different name. You must already have new git repository  (repo/app/new.git)

git remote add origin-new ssh://gituser@ip_host2/repo/app/new.git

5. Push to a new origin

git push --all origin-new

6. Push tags to a new origin

git push --tags new-origin

7. [optional] remove origin and rename new origin

git remote rm origin
git remote rename origin-new origin

 

Categories: Umum
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: