在git拉origin master之后,我得到了以下消息:
warning: Pulling without specifying how to reconcile divergent branches is
discouraged. You can squelch this message by running one of the following
commands sometime before your next pull:
git config pull.rebase false # merge (the default strategy)
git config pull.rebase true # rebase
git config pull.ff only # fast-forward only
You can replace "git config" with "git config --global" to set a default
preference for all repositories. You can also pass --rebase, --no-rebase,
or --ff-only on the command line to override the configured default per
invocation.
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), 51.49 KiB | 850.00 KiB/s, done.
拉动似乎成功了,但我不确定。
我该怎么补救呢?
这是Git 2.27中添加的一个新警告:
* "git pull" issues a warning message until the pull.rebase
configuration variable is explicitly given, which some existing
users may find annoying---those who prefer not to rebase need to
set the variable to false to squelch the warning.
要删除警告,如果你没有在命令行上指定行为(使用——ff,——no-ff,——ff-only,——rebase),将建议值之一设置为git拉取的首选默认行为。在所有情况下,如果可能的话,git都会尝试快进(什么是git快进?)这些设置控制在您的分支中发生更改但未在远程分支中显示时发生的情况。
git config pull.rebase false # merge (the default strategy)
这是现有的默认行为;设定为不发出警告,也不改变行为;Git会将远程分支合并到本地分支中。
git config pull.rebase true # rebase
在这里,git将尝试在远程分支的顶部重新基于您的更改。什么时候我应该使用git pull -rebase?关于你为什么想要那样做的更多细节。
git config pull.ff only # fast-forward only
如果快进合并是不可能的,git将拒绝继续。git pull -rebase和git pull -ff-only引号的区别:
拒绝合并并以非零状态退出,除非当前HEAD已经是最新的,或者合并可以作为快进解决
该问题将通过以下命令解决
Git配置-全局拉。Ff true在项目目录终端执行此命令。
这是一个理想的解决方案,通过桌面,但同时。对于不熟悉CLI (Command Line Interface)的用户,可以参考本手册。
从GitHub桌面,您可以按Ctrl + '(也可从
“存储库”主菜单为“在[您设置的终端]中打开”)。这
应该打开一个CLI。
从SourceTree -> Actions ->打开终端。这个会打开
终端与您的项目目录。
在终端输入:
Git配置-全局拉。Ff为真(或错误提示中指定的任何其他选项)。
现在,当你试图拉它将使用该配置,并允许你继续。
我建议拉。Ff为真,因为它试图在应用本地提交之前快进您的分支,使其与远程更新,如果没有,它将执行从远程到本地分支的合并。点击这里阅读文档。
通常情况下,当您拖动一个分支、添加提交和推送时。这是在顺序假设您的本地是最新的远程。当无法快速转发时,通过合并,您将看到一个合并提交通知您它是如何处理的。(其他的选择是rebase或总是合并,许多新用户发现rebase不太直观,但实际上完成了同样的事情)
我添加了——global标志,这样你的选择将适用于你所有的回购,你不会再看到这个错误消息。如果您希望每个存储库都有不同的行为,可以忽略这个选项。