Michal Kordas
Michal Kordas

Reputation: 10925

Git fast-forward merge to preserve original committer and committer date

While I'm doing something like

git merge --ff-only someBranch

author and author date are nicely preserved, but committer and committer date are overwritten.

How can I do fast-forward merge and preserve original committer and committer date?

Documentation doesn't help at all.

Upvotes: 0

Views: 710

Answers (1)

poke
poke

Reputation: 387507

A fast-forward merge does not do any actual merging: It neither introduces a new merge commit, nor does it touch any of the existing commits (that would be a rebase, which can be a harmful operation). Instead, a fast-forward merge only changes the current branch pointer to the target commit.

So in your case, when you do git merge --ff-only someBranch, your current branch, e.g. master will be changed to point at the same commit that someBranch points at. The --ff-only option prevents Git from performing an actual merge, so it won’t create a merge commit there but only ever fast-forward.

This should not change the commit at all, and preserve every property of the commits. If you see a different committer for commits you merged with --ff-only, then they had those values already before merging them.

Upvotes: 2

Related Questions