First, the big picture: I'm trying to write a git post-receive script for a Redmine / Gitolite server I'm running. As per various recommendations, I'm creating a bare and local repository for Redmine to read from, and I'm setting up a post-receive script on Gitolite to push changes into the Redmine repo.
However, I'm very noobish with Git, so I'm unable to even do a simple task here >_<. I think if I figure this out, I should be able to write the above script. After setting up my test repo, I've created two repos as a test.
(The "Central Repo" is a Gitolite repository at 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
Now when I run ls:
$ ls
testing testing2 testing.git
Now, I change the test file inside of the testing2, and then push the changes to the central repo.
$ cd testing2
$ echo 'testline' >> test && git commit --allow-empty-message -a -m '' && git push
As expected, if I run "git pull" on the "testing" folder, everything works as expected.
$ 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
$
As shown with the last "diff", the "testing" directory and "testing2" directory work exactly as expected. The "git pull" command synchronizes the two directories.
However, if I cd into testing.git (aka: the bare repo), a git fetch / git reset --soft fails to update the bare repo to the latest version.
$ 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
As you can see from the last example, the bare repository failed to get updated, and there is somehow a difference between the two files. What did I do wrong?
Thanks in advance