fast-forward

Git: Prevent commits in master branch

亡梦爱人 提交于 2019-11-26 10:10:51
问题 (For simplicity) I have a master branch and a dev in my Git-repo. I want to ensure the master branch is always working, so all work I do should be in the dev branch. However, when I merge my changes in with a --no-ff merge, I tend to stay in the master branch, and just continue working in it (because I forget to checkout my dev branch). Can I put up a rule for the master branch, which states I can\'t do commits, and fast-forward merges, but only --no-ff merges from another branch? This must

Can I make fast forwarding be off by default in git?

不打扰是莪最后的温柔 提交于 2019-11-26 04:56:57
问题 I can\'t really ever think of a time when I would use git merge rather than git rebase and not want to have a commit show up. Is there any way to configure git to have fast forwarding off by default? The fact that there\'s an --ff option would seem to imply that there\'s a way, but I can\'t seem to find it in the documentation. 回答1: Yes, there is --no-ff . You can configure merge options per branch, e.g. git config branch.master.mergeoptions "--no-ff" adds the following to your $(REPO)/.git

What is the difference between `git merge` and `git merge --no-ff`?

人走茶凉 提交于 2019-11-26 00:49:16
问题 Using gitk log , I could not spot a difference between the two. How can I observe the difference (with a git command or some tool)? 回答1: The --no-ff flag prevents git merge from executing a "fast-forward" if it detects that your current HEAD is an ancestor of the commit you're trying to merge. A fast-forward is when, instead of constructing a merge commit, git just moves your branch pointer to point at the incoming commit. This commonly occurs when doing a git pull without any local changes.

Why does git perform fast-forward merges by default?

孤者浪人 提交于 2019-11-26 00:09:26
问题 Coming from mercurial, I use branches to organize features. Naturally, I want to see this work-flow in my history as well. I started my new project using git and finished my first feature. When merging the feature, I realized git uses fast-forward, i.e. it applies my changes directly to the master branch if possible and forgets about my branch. So to think into the future: I\'m the only one working on this project. If I use git\'s default approach (fast-forward merging), my history would