初始化/複製git程式庫


初始化一個Repository
git init

初始化一個server形式的Repository(看不到原始碼檔案)
git init --bare

複製某個Repository
git clone https://gogojimmy@github.com/gogojimmy/Animal.git

複製某個Repository並該資料夾命名成monkey
git clone https://gogojimmy@github.com/gogojimmy/Animal.git monkey

Clone並切到指定的branch(和一般clone只差在clone完後是在指定的branch)
git clone -b 
git clone --branch  
如果不存在該branch,就還是會用default branch

只抓Repository中的一個branch(git --version > 1.7.9)
git clone -b --single-branch

因為上面的指令需要等高版本,要安裝更高版本可以透過下面這個ppa
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

Shallow clone 

git clone --depth=1 https://gogojimmy@github.com/gogojimmy/Animal.git
git fetch --depth=10 # 10 can be any positive number 

解除Shallow clone
git fetch --unshallow

留言