LoginSignup
10
9

More than 5 years have passed since last update.

Gitリポジトリをバックアップする

Last updated at Posted at 2015-08-26

手順

backup_git_repository.sh
set -eu

WORK_DIR="/path/to/work/directory"
GITHUB_USERNAME="artifactsauce"
REPOSITORY="hogehoge"

[ -d $WORK_DIR ] || mkdir $WORK_DIR
cd $WORK_DIR
git clone --mirror git@github.com:${GITHUB_USERNAME}/${REPOSITORY}.git
cd ${REPOSITORY}.git
git fetch --all
git remote remove origin
cd $WORK_DIR
tar zcvf ${REPOSITORY}.tar.gz ${REPOSITORY}.git

どこでホストされているリポジトリでも基本的には同じですが、ここではGitHubでホストされたリポジトリを例にしています。

補足

ローカルシステム上のリポジトリをバックアップする場合は、Unixファイルシステム上のPATHを指定します。また --no-local オプションをつけることでハードリンクを作成させないようにします。

10
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
9