gitgit-pull

Why does pulling sometimes make me create a commit?


I'm working with someone on the same branch.

I'm pulling each time after I've made changes to my working directory before I add or commit or push and only sometimes I get the below message. When does it do this and why?

Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch.

Lines starting with '#' will be ignored, and an empty message aborts the commit.


Solution

  • Simple answer: git pull is, essentially, a combination of git fetch and then a git merge.

    As any merge, if Git finds out fast-forwarding is not possible, a traditional merge is necessary (one more commit with two parents), therefore this process asks for a commit message.

    Reference: Git docs for branching and merging