When should I use “git push –force-if-includes”

TL;DR The new-in-Git-2.30 –force-if-includes does nothing unless you also include –force-with-lease. If you do use –force-with-lease, that alone can suffice. I’m not convinced of the utility of –force-if-includes myself and would personally use a multi-step process: git fetch <remote> # get commit(s) from remote git show <remote>/<name> # inspect their most recent commit # to … Read more

Making a Git push from a detached head

If you are on a detached head and you want to push to your remote branch git push origin HEAD:name-of-your-branch otherwise you can create a new branch and push to it ( it will be created automatically ) git branch new-branch-name git push -u origin new-branch-name

Git push only for bare repositories?

Read the warning carefully. The new default prohibition is only on pushing to the currently checked out branch in a non-bare repository. It is perfectly OK to push to any other branch in a non-bare repository. The reason for this is that the push process has no direct access to the working tree so the … Read more

Fix GitLab error: “you are not allowed to push code to protected branches on this project”?

there’s no problem – everything works as expected. In GitLab some branches can be protected. By default only Maintainer/Owner users can commit to protected branches (see permissions docs). master branch is protected by default – it forces developers to issue merge requests to be validated by project maintainers before integrating them into main code. You … Read more