Kinaconの技術ブログ

Ubuntuはじめました。

git cloneでローカルリポジトリを登録する

f:id:m-oota-711:20190505160131p:plain

github/外付けHDDなどに作成したリモートリポジトリをクローンして ローカルリポジトリにする。


実行環境 ver
Ubuntu 18.04.2 LTS
GIT 2.17.1


githubの場合

# ローカルリポジトリとするディレクトリを作成する
$ mkdir test_github

# ディレクトリにgithubのリポジトリをクローンする
$ git clone https://github.com/<user_name>/<repogitory_name> test_github/

> Cloning into 'test_github'...
> Username for 'https://github.com': <user_name>
> Password for 'https://<user_name>@github.com':<password>

> remote: Enumerating objects: 17478, done.
> remote: Counting objects: 100% (17478/17478), done.
> remote: Compressing objects: 100% (11139/11139), done.
> remote: Total 17478 (delta 6097), reused 17475 (delta 6094), pack-reused 0
> Receiving objects: 100% (17478/17478), 738.25 MiB | 2.80 MiB/s, done.
> Resolving deltas: 100% (6097/6097), done.
> Checking out files: 100% (21152/21152), done.


外付けHDDなどローカルディレクトリの場合

# ローカルリポジトリとするディレクトリを作成する
$ mkdir test_hdd

# ディレクトリにHDD内のリポジトリをクローンする
# HDD内のリポジトリのパス:/media/<user>/<HDD_name>/<repogitory_name>

$ git clone /media/<user>/<HDD_name>/<repogitory_name> test_hdd/


リモートリポジトリがclone元か確認する

URLもしくはPATHがクローン元と同じならOK

$ cd test_github or cd test_hdd
$ git remote -v

> origin URL or PATH (fetch)
> origin URL or PATH (push)

以上。