如何配置“git pull -ff-only”和“git merge --no-ff” [英] How to configure "git pull --ff-only" and "git merge --no-ff"

查看:1999
本文介绍了如何配置“git pull -ff-only”和“git merge --no-ff”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对我来说,一个典型的git工作流程是克隆一个远程仓库,并使用git pull来保持它的最新状态。我不希望合并提交时,我拉,所以我使用 - 只有选项。



我也使地方分支功能工作。我想保留分支历史记录,所以当我将本地分支合并回本地克隆时,我使用了--no-ff选项。



如何配置混帐默认使用这些选项?目前我的.gitconfig如下所示:

  [merge] 
ff = false
[pull]
ff =只有

然而,git pull(这真的是git fetch和git merge)似乎这个应该不是这样的,根据 git-config 手册页 on pull.ff


(.. 。)如果设置为仅,则只允许进行这种快进合并(相当于从命令行提供--ff-only选项)。 此设置在拉动时覆盖merge.ff。


配置 pull.ff 已经在Git 2.x中引入,所以它在Git 1.x上不会像预期的那样工作 - 它可能会拾取 merge.ff 配置并在执行Pull时使用它。


A typical git workflow for me is to clone a remote repository and use git pull to keep it up-to-date. I don't want merge commits when I pull, so i use the --ff-only option.

I also make local branches for feature work. I want to preserve the branch history, so when I merge the local branch back to my local clone, I use the --no-ff option.

How can I configure git to use those options by default? Currently my .gitconfig looks like this:

[merge]
  ff = false
[pull]
  ff = only

However, git pull (which is really git fetch and git merge) seems to be picking up the merge option and therefore creating merge.

解决方案

That shouldn't be the case, according to the git-config man page on pull.ff:

(...) When set to only, only such fast-forward merges are allowed (equivalent to giving the --ff-only option from the command line). This setting overrides merge.ff when pulling.

The configuration pull.ff has been introduced in Git 2.x, so it won't work as expected on Git 1.x -- it will probably pick up the merge.ff configuration and use that when doing a Pull.

这篇关于如何配置“git pull -ff-only”和“git merge --no-ff”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆