We are using Github Desktop (formerly Github for Windows) as our Git client. We frequently have the following situation:
Developer A commits a bunch of updates with lovely explanatory messages. Developer B has been working in the same branch and makes a commit afterwards, with a message.
Developer B's commit with the message shows up in the git log, and following it, we get a merge commit from Developer B, with an automatic message "merge branch ...". The merge commit contains all of Developer A's changes, but Developer A's lovely messages are gone. It seems like this behavior has changed somewhat -- it used to happen very rarely, and now seems to happen all the time.
(It's hard to find up-to-date info on what the "Sync" button in Github Desktop is doing, exactly, but I did find a reference suggesting that it used to do git pull --rebase
and then changed. That seems to fit with the fact that this merge commit issue is much worse than it used to be.)
So my question is: is there any way to prevent the loss of Developer A's commit message?
EDITED TO ADD: Seems like the issue is two-fold: 1) our developers aren't always doing a pull before committing, resulting in merge commits. The original commits are not lost, but aren't visible. 2) The way Github Desktop is displaying the log is showing the merge commits but not showing the original commit. Here's a comment I got in email from the Github Desktop team:
Digging into this further, it does look like the commits are being hidden due to the --first-parent flag that we use when showing the history in GitHub Desktop. Currently there isn't a way to change this behavior.
Here's some of the rational behind why we do this that a developer of GitHub Desktop shared:
"GitHub Desktop is optimized for GitHub Flow. In this model, merges almost always represent either (1) a branch getting merged into the default branch via a pull request or (2) a branch being updated from the default branch.
In the first case, it's most useful to see which pull requests have been merged—not the individual commits that make up that pull request. We think pull requests are amazing and very useful for understanding history, so we want to prioritize them.
In the second case, seeing the commits that came in with a merge only obscures the changes on the branch. It's most useful to see the commits that are unique to the branch."
We're ending up feeling like probably Github Desktop isn't a good fit for us -- I've personally switched to GitKraken, and a lot of us are using the command line more.
The developer A's commit messages are not lost, probably. It is the way the Github Desktop application shows the commits.
You can check whether you actually lost the commits by running git log --graph
.
If you want a client that shows the merged commits, you can use SourceTree or TortoiseGit.
See this answer and this question for more details.