What are the differences between `–squash` and `–no-ff –no-commit`?

The differences These options exists for separate purposes. Your repository ends up differently. Let’s suppose that your repository is like this after you are done developing on the topic branch: –squash If you checkout master and then git merge –squash topic; git commit -m topic, you get this: –no-ff –no-commit Instead, if you do git …

Read more

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