Git repository selection and migration

Source: Internet
Author: User

In the previous article, I showed a script for Debian system configuration. In addition to the configuration, the new computer has another problem ...... Resource migration! (For general resources, scp can be used for copying. Of course, the scp speed in the LAN is considerable, but for special resources such as git repository, using scp directly may affect the use of git repository !)

In my personal habits, I put all git repositories in a directory called repository. If you check dirs/in this directory one by one /. git/config address, and then one git clone to re-build the repository directory on another machine seems a little unprofessional, so I wrote a very simple script (my_repository.sh) read the address in the repository, append all the addresses to a file, and then use another script (clone. sh.

First, let's take a look at the shell script for collecting git repository addresses:

#! /Bin/bash
# (C) 2014 Yunlong Zhou <reaper888@yeah.net>
# Under licence GPL
# File: my_repository.sh
# Introduction:
# This script is using for collect all the git address to a file -- repository_file
# Useage:
#1. cd repository -- cd to the dir that you store all the git repository
#2. chmox + x my_repository.sh -- give the script a execute permission
#3 ../my_repository.sh


# For delete old temp file, if there is!
If [-f all_dir-a-f repository_file]; then
Echo "Now delete old temp file"
Rm all_dir repository_file 2>/dev/null
Fi

# Read all the items under this dir to the file all_dir
Ls-l | awk '{print $9}'> all_dir
# Deal with every git repository dir and collect the url then store to file repository_file
While read FILE_NAME
Do
If [$ FILE_NAME! = ""-A-d $ FILE_NAME-a-s $ FILE_NAME]; then
Echo "Now dealing the" $ FILE_NAME
If [-d $ FILE_NAME/. git]; then
Grep-e "url" $ FILE_NAME/. git/config | cut-d "="-f2 | cut-d ""-f2> repository_file
Fi
Fi

Done <all_dir
# Remove temp file and give a Hint!
Rm all_dir
If [$? = 0]; then
Echo "OK, all the url of your repository have been send to file -- repository_file"
Fi

Now, the git repository address under all repository directories has been added to the repository_file file, for example:

Bkjia.com @ zhouyl :~ /Repository $ cat repository_file
Git: // git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
Git: // gitorious.org/tinylab/pleac-shell.git
Git: // git.kernel.org/pub/scm/linux/kernel/git/clrkwllms/rt-tests.git
...
More than a dozen personal warehouses are omitted here

Now we can use scp to copy the repository_file file and the following script to the newly installed computer (scp repository_file clone. sh bkjia.com@192.168.2.110:/tmp/) and then run clone directly. sh (. /clone. sh!

#! /Bin/bash
# (C) 2014 Yunlong Zhou <reaper888@yeah.net>
# Under licence GPL
# File: clone. sh
# Introduction:
# This script is using for git clone every item in repository_file
# Useage:
#1../clone. sh

If [! -F repository_file]; then
Echo "There is no repository_file, we will exit"
Exit
Fi

While read READLINE
Do
Echo "Now we will clone $ READLINE"
Git clone $ READLINE
Done <repository_file

Rm repository_file

Git details: click here
Git: click here

Recommended reading:

Fedora downloads Git through Http Proxy

Install Git on Ubuntu Server

Create a Git repository on the server (Ubuntu)

Git simple tutorial in Linux (taking Android as an example)

Git authoritative guide PDF

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.