1

I know that git update-index skip-worktree can be used to ignore a file from any changes. I don't want to run this command manually on every system, how can I write a node js script to do this with a npm command.

1 Answer 1

2

You have approaches for formatting code (here or in okonet/lint-staged issue 170 which takes advantages of a script section of a package.json

You could use that for instance in the prepare step, which is run both before the package is packed and published, on local npm install without any arguments, and when installing git dependencies.

{
  "scripts": {
    "prepare": "git update-index --skip-worktree -- afile",
  }
}
Sign up to request clarification or add additional context in comments.

2 Comments

The command fails on my mac, adding extra -- fix this: git update-index --skip-worktree -- afile. My git version is 2.21.0.
@EviSong thank you for this feedback. I have edited the answer accordingly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.