git update-index --assume-unchanged对我不起作用 [英] git update-index --assume-unchanged not working for me

查看:103
本文介绍了git update-index --assume-unchanged对我不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个构建Web应用程序的项目中.我们使用Git进行版本控制,并使用Gulp进行任务自动化.我想暂时忽略文件到某个文件夹,即build文件夹.我们倾向于在一天结束时(或在编码会话结束时)将更改提交到该文件夹​​.

I am in a project building a web app. We use Git for version control and Gulp for task automation. I would like to temporarily ignore files to a certain folder, the build folder. We tend to commit changes to that folder at the end of the day (or at the end of a coding session).

经过一番研究,我发现以下命令开始忽略对文件的更改:
$ git update-index-假定未更改的路径/到/文件

After some research I found the following command to start ignoring changes to a file:
$ git update-index --assume-unchanged path/to/file

当我运行该代码以忽略构建文件夹时,我会在终端上看到:忽略路径build/

When I run that code to ignore the build folder I see on the terminal: Ignoring path build/

但是它仍然显示未对该文件夹进行的更改,因此我必须在每次提交之前运行 git checkout-build/.

But it still shows changes not staged for that folder so that I have to run git checkout -- build/ before each commit.

我在做什么错了?

我在具有基本操作系统(基于Ubuntu的发行版)的PC上使用git 2.9.3.

I am using git 2.9.3 on a PC with elementary OS (Ubuntu-based distro).

推荐答案

您不应使用该位更改文件.

You're not supposed to change the file with that bit.

打开假定不变"位时,用户承诺不更改文件,并允许Git假定工作树文件与索引中记录的文件匹配.

When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index.

它旨在节省大型项目的时间.

It's intended to save time on big projects.

在lstat(2)系统调用非常慢的文件系统(例如cifs)上处理大型项目时,这有时会很有帮助.

This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).

我认为您正在寻找-[no-] skip-worktree

当指定这些标志之一时,为路径记录的对象名称不会更新.而是使用这些选项设置和取消设置路径的"skip-worktree"位.

When one of these flags is specified, the object name recorded for the paths are not updated. Instead, these options set and unset the "skip-worktree" bit for the paths.

用法:

git update-index --skip-worktree <file>

再次开始跟踪:

git update-index --no-skip-worktree <file>

您可能会忘记跳过的内容,因此我创建了一个别名:

You might forget what you have skipped, so I have an alias created:

[alias]
    skipped = !git ls-files -v | grep --color "^S"

这篇关于git update-index --assume-unchanged对我不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆