问题
Something went really wrong here. Allow me to give the background.
Today I try to push to our company default bare msysgit windows server and get a dreaded error message duplicated everywhere in SO about pushing to non-bare. I thought the message was weird, since my server was supposed to be bare. And yesterday it was working just fine.
Then I noticed the core.bare
is, somehow, set to false
! This was a repo inited with --bare
and it never had a ".git
" folder in it. And then I go check, and there it is, a .git folder, that to me appeared out of nowhere, to my dismay! I ask the only other person who could have done something there and, surely enough, he didn't.
edit: I just noticed it only happens with master
branch and the server's .git
seem to have been created on october 1st, which can be right since I don't push to master
that often.
The folder has 3gb and the bare folder, with all git structures beside the ghostly .git
, has 6gb. While my local .git has 16 gb, so I'm not sure what's going on there... Even more, I can't check git log
or git reflog
. Either setting bare to true or false I get same error fatal: bad default revision 'HEAD'. And now I think it's already time to consider how to recover the repo...
But before I go through all the restoration dogma, I wonder:
- Is there some kind of git activity log so I can see all commands issued in git, and by who?
Couldn't find anything similar, and I fear there isn't.
回答1:
That is why we have installed gitolite V3 (by simply cloning its repo and installing it like in this installation script) on our central git repo server.
Gitolite will intercept any git commands, and (in addition of its primary authorization framework feature) will record said commands in ~/.gitolite/logs/gitolite-log-xxx
.
Here is an extract of such logs:
2012-08-16.12:20:19 29507 system,/home/gitadmin/gitolite/bin/triggers/post-compile/update-git-configs,POST_COMPILE
2012-08-16.12:20:19 29507 system,/home/gitadmin/gitolite/bin/triggers/post-compile/update-gitweb-access-list,POST_COMPILE
2012-08-16.12:20:19 29507 system,/home/gitadmin/gitolite/bin/commands/access,%,gitweb,R,any
2012-08-16.12:20:19 29507 system,/home/gitadmin/gitolite/bin/commands/git-config,-r,%,gitweb\.
2012-08-16.12:20:19 29507 system,/home/gitadmin/gitolite/bin/triggers/post-compile/update-git-daemon-access-list,POST_COMPILE
2012-08-16.12:20:20 29507 system,/home/gitadmin/gitolite/bin/commands/access,%,daemon,R,any
2012-08-16.12:20:20 29507 END
2012-08-20.07:39:12 17683 ssh ARGV=gitoliteadm SOC=git-upload-pack 'gitolite-admin' FROM=127.0.0.1
2012-08-20.07:39:12 17683 access(gitolite-admin, gitoliteadm, R, 'any'),-> refs/.*
2012-08-20.07:39:12 17683 trigger,Writable,access_1,ACCESS_1,gitolite-admin,gitoliteadm,R,any,refs/.*
2012-08-20.07:39:12 17683 pre_git gitolite-admin gitoliteadm R any -> refs/.*
2012-08-20.07:39:12 17683 system,git,shell,-c,git-upload-pack '/home/gitadmin/repositories/gitolite-admin.git'
2012-08-20.07:39:12 17683 END
2012-08-16.12:20:19 29507 system,/home/gitadmin/gitolite/bin/triggers/post-compile/update-git-configs,POST_COMPILE
2012-08-16.12:20:19 29507 system,/home/gitadmin/gitolite/bin/triggers/post-compile/update-gitweb-access-list,POST_COMPILE
2012-08-16.12:20:19 29507 system,/home/gitadmin/gitolite/bin/commands/access,%,gitweb,R,any
2012-08-16.12:20:19 29507 system,/home/gitadmin/gitolite/bin/commands/git-config,-r,%,gitweb\.
2012-08-16.12:20:19 29507 system,/home/gitadmin/gitolite/bin/triggers/post-compile/update-git-daemon-access-list,POST_COMPILE
2012-08-16.12:20:20 29507 system,/home/gitadmin/gitolite/bin/commands/access,%,daemon,R,any
2012-08-16.12:20:20 29507 END
2012-08-20.07:39:12 17683 ssh ARGV=gitoliteadm SOC=git-upload-pack 'gitolite-admin' FROM=127.0.0.1
2012-08-20.07:39:12 17683 access(gitolite-admin, gitoliteadm, R, 'any'),-> refs/.*
2012-08-20.07:39:12 17683 trigger,Writable,access_1,ACCESS_1,gitolite-admin,gitoliteadm,R,any,refs/.*
2012-08-20.07:39:12 17683 pre_git gitolite-admin gitoliteadm R any -> refs/.*
2012-08-20.07:39:12 17683 system,git,shell,-c,git-upload-pack '/home/gitadmin/repositories/gitolite-admin.git'
2012-08-20.07:39:12 17683 END
回答2:
you can use reflog to see how the references were moving, that registers activity sometimes not visible from usual git log (like fast-forward merges) but i don't think it should matter in your case.
I believe you have structure like that (it is by the way recommended to put .git extension to bare repo name, so it is easy to distinguish): ../core.bare.git/ containing branches, config, HEAD, hooks, info, objects, etc ../core.bare.git/.git containing its own set of branches, config etc I think you repo on the server is totally fine, you just have to remove the .git folder from it and double check that the config file is still saying it is a bare repo.
来源:https://stackoverflow.com/questions/12820167/is-there-a-git-activity-log