git init --bare
git
用法
git init --bare [--shared=group] <directory>.git建立沒有工作目錄的儲存庫,專門用來接收 push;裡面的檔案無法編輯,但也不會因為分支正被簽出而拒絕 push。
常用選項
| 選項 | 含義 |
|---|---|
| --bare | no working tree; only the contents of .git |
| --shared=group | let one unix group push into it |
| -b <name> | name the first branch |
| --template=<dir> | seed it with hooks from a template directory |
範例
git init --bare /srv/git/app.gitcreates a repository to push into over ssh
git init --bare --shared=group team.gita shared repository a unix group can all write to
git init --bare ~/backup/app.gita push target on a backup disk
難的地方在於復原有好幾種:把分支的指向挪走,和補一個反向提交,不是一回事。
怎麼看
- 方括號 [ ] 表示這部分可以不寫。
- 省略號 … 表示可以寫多個。
- 選項區分大小寫——有些命令裡 -r 和 -R 不是一回事。
常見問題
Q. git init --bare 是做什麼的?
建立沒有工作目錄的儲存庫,專門用來接收 push;裡面的檔案無法編輯,但也不會因為分支正被簽出而拒絕 push。
Q. 怎麼寫?
git init --bare [--shared=group] <directory>.git —— 方括號表示可以省略的部分。
Q. 值得記的選項有幾個?
這裡列了 4 個,完整列表在 man git。這條命令屬於git。
相關命令
man 手冊: man git-init---bare