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.
In the first stage of operation git pull will execute a git fetch scoped to the local branch that HEAD is pointed at. Once the content is downloaded, git pull will enter a merge workflow. A new merge commit will be-created and HEAD updated to point at the new commit.
If you have uncommitted changes, the merge part of the git pull command will fail and your local branch will be untouched. Thus, you should always commit your changes in a branch before pulling new commits from a remote repository.
By default, the git pull command performs a merge, but you can force it to integrate the remote branch with a rebase by passing it the --rebase option.
A commit is a discrete change to one or more files. It is a critical part of Git. A pull request is a request to merge one or more commits into a different branch. It is not part of Git; it is only part of GitHub (and similar services like BitBucket).
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
Please use git pull --rebase
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With