gpt4 book ai didi

由于更改了文件,Git 不会 pull

转载 作者:太空狗 更新时间:2023-10-29 13:54:59 29 4
gpt4 key购买 nike

假设我更改了文件,然后进行 pull 。 Git 会报错,因为本地仓库还没有保存,将被覆盖。如果我然后删除该添加并使文件与以前相同(与远程 repo 相同),那么会发生 pull 吗?

最佳答案

是的。这是常见的情况,您在工作目录中进行了一些更改,然后需要 pull 。通常你必须选择:

  • 永久删除您的更改,然后 pull :

    $ git reset --hard
    $ git pull
  • 将您的更改收起,执行 pull 操作,然后将您的更改放回原处:

    $ git stash
    $ git pull
    $ git stash pop # May result in a merge conflict
  • 在 pull 之前提交您的更改:

    $ git add -A .                     # stage all changes
    $ git commit -m "my commit message"
    $ git pull # May result in a merge conflict

如果您的分支配置为使用“rebase”而不是默认的“merge”,我只能推荐最后的选择(使用提交)。

来自 https://git-scm.com/docs/git-config

branch.<name>.rebase When true, rebase the branch <name> on top of the fetched branch, instead of merging the default branch from the default remote when "git pull" is run. See "pull.rebase" for doing this in a non branch-specific manner.

When preserve, also pass --preserve-merges along to git rebase so that locally committed merge commits will not be flattened by running git pull.

When the value is interactive, the rebase is run in interactive mode.

NOTE: this is a possibly dangerous operation; do not use it unless you understand the implications (see git-rebase[1] for details).

关于由于更改了文件,Git 不会 pull ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38592621/

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