2

We have a central git bare, which all users clone from and we use it for sync between the users.

Currently this directory has become huge, and we want to delete it's old history.

The problem is that deleting the history will change the hashing of the kept commits. I want to use the "pre-receive" hook to detect that the user is trying to push from a new clone and not an old one before the change.

The command "git rev-list --max-parents=0 HEAD" should give me the hash if the first commit, the problem is that when pre-receive is executed we are already in the bare repo, and i need to determine also what is the starting point of the user data.

So, how can I know what is the user directory?

Vinay Veluri
  • 6,671
  • 5
  • 32
  • 56
Kamil.Khoury
  • 210
  • 2
  • 9

2 Answers2

0

You don't have information about the origin of a push.

You could check the commit message in your hook, in order to check a pre-defined policy which says:

from now on, if you want to push to that repo, you need to include some information in the commit message allowing the central repo to identify the first commit of your downstream repo.

But that is something which requires communication with your users in order to be put in place.
It is not something that Git could enforce on its own.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

Thank for all the answers. I have found the solution to be simply to use a perl script as the pre-receive and then if i check the ${ENV{PWD}} i have the directory of the user.

Kamil.Khoury
  • 210
  • 2
  • 9