craft your forge, build your project, grow your community freely
1<!--
2SPDX-FileCopyrightText: 2025 Romain Maneschi <romain@gitroot.dev>
3 4SPDX-License-Identifier: CC-BY-SA-4.0
5--> 6 7# Force push
8 9GitRoot 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](../technicals/default_branch.md).
1011To know if a branch is protected or not, look at the `.gitroot/repoConfiguration.yml` file.
1213```yml
14defaultbranch: main
15noforcepush:
16 - main
17```1819But sometimes we need to do bad things. GitRoot permit to edit this branch in a pretty cool workflow:
20211. 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.
222. Unprotect the branch. Remove the branch from the list of `noforcepush` in `.gitroot/repoConfiguration.yml`. Commit and push.
233. 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).**
244. Push-force
255. If all is good your repository has reactivated the protection against force-push and all others users can push on this branch again.