GitHub Desktop creating large "Merge branch" commits despite there not being any branches

I’ve been using the Git for Windows GUI and command line for a few years, and I recently decided to try GitHub Desktop. Things have gone fantastically except for one thing. On certain repos, it’s been creating these “Merge branch main” or “Merge branch master” commits, even though I don’t usually use branches on personal projects.

On one project, which was a collaboration with two other people, I decided to fetch all and pull the origin after several days of inactivity. It said I had changes even though there were none, and wouldn’t let me fetch the origin until I pushed them, so I did. Doing so created a commit called “Merge branch main into main” which contained a bunch of files the other collaborators made, and undid a bunch of their changes! I went into the command line, used rebase to get rid of the bogus commit, and deleted my local copy/re-cloned the repo. I’ve never had anything like this happen with the command line and stock Git GUI.

Here is a link to one of these commits it just created. Am I doing something wrong when I’m fetching all and pulling from origin?

One thing that might be relevant - some of these repos are contained in my Dropbox sync folder.

@vince94 :wave: thanks for the question!

When you click the Pull origin button in GitHub Desktop it’s actually merging origin/master into your local master branch. GitHub Desktop does attempt to fast-forward your branches if possible (and does this in the background as well).

Merge commits usually happens when you’re collaborating on a branch with other people, and someone else has made changes to the remote version of the branch. You can force Git to always rebase commits by running this config option:

git config --global pull.rebase true

I hope that helps.