GitRoot

craft your forge, build your project, grow your community freely

Force push

GitRoot protect some branches against force-push. Force-push is bad practice and should be avoided, especially on shared branch. By default GitRoot protect your defaultBranch.

To know if a branch is protected or not, look at the .gitroot/repoConfiguration.yml file.

1defaultbranch: main
2noforcepush:
3  - main

But sometimes we need to do bad things. GitRoot permit to edit this branch in a pretty cool workflow:

  1. Make the branch writable only by you. Edit .gitroot/users.yml and remove all other users for this branch. Commit the diff and push it. By now, only you can change this branch.
  2. Unprotect the branch. Remove the branch from the list of noforcepush in .gitroot/repoConfiguration.yml. Commit and push.
  3. Now you are the only one who can touch the branch and this branch is no more protected. Make all the modification you need in your git history. Don’t forget to delete the last 2 commits (the one where your delete all others owners and the one where you unprotect the branch).
  4. Push-force
  5. If all is good your repository has reactivated the protection against force-push and all others users can push on this branch again.