有没有办法让git总是在没有快进的情况下合并,除了拉动时?
遵循一个不错的git-flow,我喜欢保留我的分支历史记录(以后更容易删除功能等),所以我在合并时将我的配置设置为 never 快进,就像这样:
git config --global merge.ff false
但是,每当我从远程更新当前分支/ pull时,它就会创建一个合并提交...这真的很糟糕,特别是在 GitHub 上分配其他项目时。
有没有让git pull
总是快进?
不幸的是,我尝试过:
git pull --ff-only upstream master
...只是看着它吐出错误:
fatal: You cannot combine --no-ff with --ff-only.
我真的厌倦了看到这个:
答案 0 :(得分:10)
你可以试试这个:
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.
答案 1 :(得分:1)
我建议你在一个单独的分支中工作并继续重新定位到远程分支而不是合并。
变化:
$ git checkout -b my-topic-branch
$ (work work work)
$ git commit
$ git checkout master
$ git pull origin master
$ git merge my-topic-branch
人:
$ git checkout -b my-topic-branch
$ (work work work)
$ git commit
$ git fetch origin
$ git rebase origin/master
$ git checkout master
$ git merge my-topic-branch
如果这些配置组合不起作用,我认为你已经离开了。