gpt4 book ai didi

git - --assume-unchanged 同步文件会发生什么?

转载 作者:太空狗 更新时间:2023-10-29 14:41:05 26 4
gpt4 key购买 nike

我正在开发一个 git 代码库。我想更改服务器跟踪的项目 xml 文件。我想以这样的方式进行设置:

  • 我的本地更改应该被忽略并且永远不会发送到服务器。
  • 服务器应该同步覆盖我的本地更改。

目前我在用

git update-index --assume-unchanged [my file name]

但我不确定服务器更新时会发生什么。

最佳答案

来自docs

--[no-]assume-unchanged

... When the "assume unchanged" bit is on, [this] allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git.

Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.

因此,您需要在引入更改之前git update-index --no-assume-unchanged 文件。

例子

$ git status

Changes not staged for commit:

modified: some-file.txt

$ git update-index --assume-unchanged some-file.txt

$ git status

nothing to commit, working tree clean

$ git pull

a1b2c3d4..a4b3c2d1 master -> origin/master
Updating a1b2c3d4..a4b3c2d1
error: Your local changes to the following files would be overwritten by merge:
some-file.txt
Please commit your changes or stash them before you merge.
Aborting

关于git - --assume-unchanged 同步文件会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57262198/

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