Git 忽略类型变更

问题描述 投票:1回答:1

TLDR

我希望能够在不同的项目中同时改变两个文件。

长版

我想用git只跟踪我的文件内容的变化,我不关心那些所谓的 "内容"。typechange 变化。我可以更改我的git配置或编辑我的 .gitignore 文件?

我有一个文件 ~/proj/real_foo 的内容与被跟踪的 ./foo 不过 我希望能够在不同的项目中同时改变这两个文件。

目前。

> ls
foo
> git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
> rm foo; ln -s ~/proj/real_foo ./foo
> git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    typechange: foo

no changes added to commit (use "git add" and/or "git commit -a")

理想的。

> ls
foo
> git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
> rm foo; ln -s ~/proj/real_foo ./foo
> git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
bash git ignore
1个回答
2
投票

Git 并没有提供忽略类型变化的方法。 这是一个特殊的情况,与一般的忽略对跟踪文件的修改不同,答案是,Git 没有提供这个选项。 试图使用 git update-index 通常提出的建议 行不通,正如文件中所说。

在这里你可以做的是忽略 foo 并为它提供一些模板,由你的构建系统复制过来,如果不存在的话,则由脚本复制过来。 由于存在一个符号链接,它将被保留,同时还能使代码在一个全新的克隆文件上工作。 你也可以让你的构建系统或脚本只用符号链接来代替模板文件。

© www.soinside.com 2019 - 2024. All rights reserved.