GIT: Fast-forwhat ?

What’s Fast-forward in GIT !

Continuing to explore what wasn’t clear for me, I wanted to dive into Fast-Forward algorithm/method in GIT.

I had a simple question: what is it ?

Well, let say that you’re implementing a new feature. Normally, you’ll create a new branch (eg: feature/that-thing). Then, you’ll start to commit in it. And finally, you’re merging the branch on the main branch (eg: develop). Thus, closing the branch and ending the normal workflow.

GIT has two method to merge your work:
– Fast-Forward
– 3-way merge

Fast-Forward

Let say that you’re creating a branch which will handle only one commit (eg: a fix). You finished it after 4 minutes and nobody push on the main branch. The question that you should ask yourself is: « Why did I created a branch ? it’s useless no ? ». Let’s be clear: « IT ISN’T » !!! Asking GIT to use the fast-forward method will solve the problem ! GIT will just move the HEAD on your commit as if your branch never existed ! It will not create a new merging commit. Hence, only one commit will be displayed: yours !

NOTE: you can have multiple commits. As soon a noone commited something between your newly created branch and your last commit !

3-way merge

Basically, it will create a new commit with a merge message.

Discussion

A lot of people are asking not to use Fast-Forward to normalized and to see those merge message. Other people don’t like that and prefer to have a clean and clear philosophy: big feature should provide a merge message while small fixes can be a simple commit. This is your choice !

Leave a Reply

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *