Skip to content

Instantly share code, notes, and snippets.

@xhlwill
Last active February 16, 2023 07:43
Show Gist options
  • Save xhlwill/5f06394f0c003d097d758e87a5e34630 to your computer and use it in GitHub Desktop.
Save xhlwill/5f06394f0c003d097d758e87a5e34630 to your computer and use it in GitHub Desktop.
git 忽略某个文件夹的修改状态

git update-index wants the file names on it's command line.

Step 1:

cd into the folder you want to assume is unchanged,

Step 2:

You can do either this:

git update-index --assume-unchanged $(git ls-files | tr '\n' ' ')

or

git ls-files | tr '\n' ' ' | xargs git update-index --assume-unchanged

Although, with either case, file names with spaces will be problematic. If you have those, you can use this:

git ls-files -z | xargs -0 git update-index --assume-unchanged

Edit: incorporated input from @MatthewScharley regarding git ls-files -z.

via: https://stackoverflow.com/questions/12288212/git-update-index-assume-unchanged-on-directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment