Search code examples
gitgitolite

How to push after making a commit that changes access-restricted files?


I have a gitolite repo with the following access rules:

repo foo
    RW+                     = admin
    RW+                     = user
    RW+ VREF/NAME/toPush.py = user
    -   VREF/NAME/          = user

The foo repo is organized like this:

foo
  --toPush.py
  --notToPush.py

What I want to do is allow the admin full access to the foo repository, but give the user push access to only the toPush.py file.

From the user side, this works if I make changes and commit ONLY the toPush.py file and push it. If even by accident I commit the notToPush.py after making changes and push, it fails (as it should).

My problem is: How do I push the updated toPush.py now that I have accidentally committed the notToPush.py? I tried to git rm --cached notToPush.py, commit the changes and push again but it still fails. I went through gitolite's official documentation, but I don't see anything regarding fixing bad commits and pushes. Does making a single commit on a file that the user does not have push privileges make it so that I can't push at all?

Thanks in advance. I apologize if there is a simple fix, I'm unable to find one.


Solution

  • Your gitolite rule is RW+, which means you can do a force push (git push --force)

    That means you can:

    • git reset @~, change your files, add, commit, and git push --force.
    • or modify directly your files, add and, as commented, git commit --amend --no-edit