gpt4 book ai didi

Git 总是在没有快进的情况下 merge ,除了 pull 时?

转载 作者:IT王子 更新时间:2023-10-29 01:02:13 24 4
gpt4 key购买 nike

有没有办法让 git 总是在没有快进的情况下 merge ,除了 pull 时?

遵循一个不错的 git-flow,我喜欢保留我的分支历史记录(以后更容易删除功能等),所以我将我的配置设置为 never 在 merge 时快进,就像这样:

git config --global merge.ff false

但是,每当我从远程更新我当前的分支/pull 时,它都会创建一个 merge 提交...这真的很恶心,尤其是对于 GitHub 上的其他项目。

有没有办法让 git pull always 快进?不幸的是,我尝试这样做:

git pull --ff-only upstream master

...只是看着它吐出一个错误:

fatal: You cannot combine --no-ff with --ff-only.

我真的厌倦了看到这个:

Gross: a "git pull" merge commit

最佳答案

你可以试试这个:

git pull --rebase upstream master

这将在上游提交之上重新设置您的提交。

这是它的作用的图示。

您的本地存储库:

* bbbbbbb (HEAD, master) My changes.
* aaaaaaa Initial commit.

上游仓库:

* ccccccc (upstream/master) Their changes.
* aaaaaaa Initial commit.

git pull --rebase upstream master 之后:

* bbbbbbb (HEAD, master) My changes.
* ccccccc (upstream/master) Their changes.
* aaaaaaa Initial commit.

关于Git 总是在没有快进的情况下 merge ,除了 pull 时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13597171/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com