Git: preventing fast jumps only when merging external branches into a master

To simplify viewing when object branches are merged with the master, you can use the Git --no-ff option when merging your function branch with the master.

One way to do this without having to enter --no-ff is to completely disable anti-aliasing of fast forwarding to the master:

 git config branch.master.mergeoptions --no-ff 

However, this is inconvenient, since it also prevents fast forward merging when simply merging upstream changes in master to a local copy of the master (for ordinary git pull s, commit commits are created.)

Is there a way to configure Git to prevent switching from quickly switching to master only when merging function branches into master, so that when git pull executed from master fast-forward is allowed, but merge commits are always created when merging function branches? Or explicitly uses --no-ff only way to accomplish this?

+4
source share
1 answer

Note: pre-merge hook does not exist.
It was introduced in 2008, and was criticized then (since it is better to use control on the server (using the update hook).
It is in the process of reintroduction ( September 2012 )

And pre / post-commit hook is not done in auto commit done with git merge .

So:

  • or you installed the update hook on the git server where the developers click (but it might be too late for them to realize that they quickly redirected the function branch)
  • or you write (and distribute and maintain ...) a git-merge wrapper that will perform this control at the local repo level.

As I said before, fast-forward when using pull and no-ff when pressed "without using --no-ff has its advantages, since git bisect and git blame will not break.
Thus, the developer for the function may want to reorganize their salespeople (it’s a little through if there are too many of them) before redirecting them to the master branch (instead of creating one giant commit).
See Understanding git Workflow for more information.

+1
source

Source: https://habr.com/ru/post/1439028/


All Articles