1、簡易建倉--使用git倉庫的work tree 形式
項目開發中經常遇到需要共享android源碼的情況,一種方法是通過tar打包共享。由於android源碼使用manifest 倉庫來管理,因此通過分析和修改manifest 文件可以快速建立一個倉庫。
git clone manifest.git
cd manifest
分析default.xml文件,
主要修改
<remote元素 ssh://myname@>
<project 中name字段> 注意ssh://本機ip/name 應該能尋址到git倉庫
git add .
git commit -m " initial change"
git push origin master:master
即可快速修改manifest.git
然後通過repo init -u ssh://myname@ip/relativepatch/manifest.git 路徑通知同事下載。
注意使用私人服務器ssh,需要在~/.ssh/ 中添加需要下載代碼的人的pub_key.
2、mirror 建立倉庫--使用git倉庫的bare 形式
repo init -u git://android.git.kernel.org/platform/manifest.git -b master -mirror
repo sync
會在本地創建很多 .git文件夾,其中主要包括一個manifest.git。
通過修改maifest.git 可以更快速地搭建倉庫。
3、在gerrit服務上修改manifest.git需要走gerrit服務器註冊流程,如註冊郵箱,添加公鑰。
在私人服務器上修改manifest.git需要走ssh流程,需要將對方公鑰加入到本地~/.ssh/authorized_keys
4、一個最簡單的倉庫
mkdir test.git
cd test.git
git init --bare 可以生成一個bare倉庫 而git init 可以生成一個worktree倉庫
git clone test.git
cd test
vim .gitignore
touch .gitignore
git add .
git commit -m "add .gitignore"
可以表述一個基本的git倉建立和操作