Prevent commits in master branch

Yes, it is possible. You must create a pre-commit hook which rejects commits to the master branch. Git doesn’t call a pre-commit hook when you call the merge command, so this hook will be rejecting only regular commits. Go to your repository. Create a file, .git/hooks/pre-commit, with the following content: #!/bin/sh branch=”$(git rev-parse –abbrev-ref HEAD)” … Read more

Why does git perform fast-forward merges by default?

Fast-forward merging makes sense for short-lived branches, but in a more complex history, non-fast-forward merging may make the history easier to understand, and make it easier to revert a group of commits. Warning: Non-fast-forwarding has potential side effects as well. Please review https://sandofsky.com/blog/git-workflow.html, avoid the ‘no-ff’ with its “checkpoint commits” that break bisect or blame, … Read more