为什么git要求输入提交信息来解释为什么这种合并是必要的 [英] Why git asks to enter a commit message to explain why this merge is necessary
问题描述
我在本地分支有1个提交,然后从远程分支到我的本地进行更改,我在本地分支上执行了 git pull
,令我吃惊 git
表示。
#请输入提交信息以解释原因这个合并是必要的,
#特别是如果它将更新的上游合并到主题分支中。
我知道我在 vi
编辑器。
我的问题是为什么 git要求我输入消息。我从来没有面对过它。
我的git版本是: version 1.9.5-preview20141217
From Git文档:
将远程存储库中的更改合并到当前分支中。在默认模式下,git pull是git fetch的缩写,然后是git merge FETCH_HEAD
至于你的问题: WHY
- 为什么Git创建一个MERGE commit:这是
git pull
。在互联网上有很多这种行为的解释,
- 为什么Git现在要求提交提交消息:我想到了三种可能的选项:
- 您更新了您的git客户端
- 您之前从未拥有位于远程的本地分支
- 您的git配置最近已更改
- 为什么Git现在要求提交提交消息:我想到了三种可能的选项:
如何避免这种情况: 因为您的本地存储库提前1次提交,所以git会尝试将您的远程合并到本地仓库。这可以通过合并来处理,但就你而言,也许你正在寻找rebase,即将你的提交添加到顶端。您可以使用 全局设置: 或者您可以为每个分支设置它: I had 1 commit on my local branch, then to take the changes from remote branch into my local, I did a I understand that I'm in My question is why git asked me to enter the message. I never faced it before. My git version is: I referred this question but I'm still finding it hard to understand.
Thanks. From Git Documentation: Incorporates changes from a remote repository into the current branch. In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD As to your question about: WHY How to avoid this: Since your local repository is 1 commit ahead, git tries to merge your remote to your local repo. This can be handled via merge, but in your case, perhaps you are looking for rebase, i.e. add your commit to the top. You can do this with If this is indeed the behavior you are looking for, you can setup your git config to make rebase a default option for your Set it up globally with: Or you can set it up per branch:
这篇关于为什么git要求输入提交信息来解释为什么这种合并是必要的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
git rebase
或 git pull --rebase
$ b如果这确实是你正在寻找的行为,你可以设置你的git配置来使rebase成为你的的默认选项, git pull
git config branch.autosetuprebase always#强制所有新分支自动使用rebase
git config分支。* branch-name * .rebase true#强制现有分支机构使用rebase。
git pull
on my local branch and to my surprise git
said this.# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
vi
editor.version 1.9.5-preview20141217
git pull
. There are lots of explanation of this behavior on the internet, this does a good job of explaining it.
git rebase
or git pull --rebase
git pull
git config branch.autosetuprebase always # Force all new branches to automatically use rebase
git config branch.*branch-name*.rebase true # Force existing branches to use rebase.