$ tree repo-server
repo-server/
├── external
│ ├── example1
│ │ └── 111.txt
│ ├── example2
│ │ └── 222.txt
│ └── example3
│ └── 333.txt
└── manifest.git
└── default.xml
Start:
- $ mkdir -p $HOME/repo-service/manifest.git
$ vim default.xml<manifest> <remote name="repo-server" fetch="/home/ubuntu/repo-server" review="/home/ubuntu/repo-server" /> <default revision="master" remote="repo-server" /> <project name="external/example1" path="external/example1"/> <project name="external/example2" path="external/example2"/> </manifest>
- $ git init; git add.; git commit -m "init"
- $ mkdir -p repo-server/external/example1
- $ mkdir -p repo-server/external/example2
- 各自弄個測試檔後(如上tree結構),再加入 git init
Client side:
- 下載 repo
這樣應該可以看到external了$ mkdir repo-client; cd repo-client $ curl https://storage.googleapis.com/git-repo-downloads/repo > ./repo $ ./repo init -u /home/ubuntu/repo-server/manifest.git/ (絕對路徑) $ ./repo sync
- 修改後 push
$ git remote -v
$ git checkout -b test repo-server/master
$ git git push /home/ubuntu/test/repo-server/external/example3 HEAD:test
git push /home/ubuntu/test/repo-server/external/example2 HEAD:master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 275 bytes | 275.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD.
remote:
remote: You can set the 'receive.denyCurrentBranch' configuration variable
remote: to 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: arranged to update its work tree to match what you pushed in some
remote: other way.
remote:
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To /home/ubuntu/test/repo-server/external/example2
! [remote rejected] HEAD -> master (branch is currently checked out)
error: failed to push some refs to '/home/ubuntu/test/repo-server/external/example3'
好像是因為repo-server/externel/example2目前是在master,如果checkout到test, 就可以push到master
ref:
1. 建立本地repo 管理仓库
2. 用Git在本地電腦做備份
沒有留言:
張貼留言