首先,总体情况:我正在尝试为我正在运行的Redmine / Gitolite 服务器编写一个 git post-receive 脚本。根据各种建议,我正在创建一个裸露的本地存储库供 Redmine 读取,并且我正在 Gitolite 上设置一个接收后脚本以将更改推送到 Redmine 存储库中。
然而,我对 Git 很菜鸟,所以我什至无法在这里完成一个简单的任务 >_
(“Central Repo”是一个 Gitolite 存储库,位于 git@localhost:testing)
cd /tmp
mkdir /tmp/test
$ git clone git@localhost:testing
$ git clone git@localhost:testing testing2
$ git clone git@localhost:testing --bare
现在当我运行 ls 时:
$ ls
testing testing2 testing.git
现在,我更改testing2内的测试文件,然后将更改推送到中央存储库。
$ cd testing2
$ echo 'testline' >> test && git commit --allow-empty-message -a -m '' && git push
正如预期的那样,如果我在“testing”文件夹上运行“git pull”,一切都会按预期进行。
$ cd testing
$ git pull
remote: Counting objects: 5, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From localhost:testing
3242dba..a1ca5ba master -> origin/master
Updating 3242dba..a1ca5ba
Fast-forward
test | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
$ diff ./test ../testing2/test
$
如最后一个“diff”所示,“testing”目录和“testing2”目录完全按预期工作。 “git pull”命令同步两个目录。
但是,如果我 cd 进入testing.git(又名:裸存储库),则 git fetch / git reset --soft 无法将裸存储库更新到最新版本。
$ ls
branches config description HEAD hooks info objects packed-refs refs
$ git fetch
remote: Counting objects: 5, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From localhost:testing
* branch HEAD -> FETCH_HEAD
$ git reset --soft
$ cd ..
$ git clone ./testing.git testing3
Cloning into testing3...
done.
$ cd testing3
$ diff test ../testing2/test
5a6
> testline
从上一个示例中可以看出,裸存储库无法更新,并且两个文件之间存在某种差异。我做错了什么?
提前致谢