1

tl;dr: Is it possible to add only parts of file to git staging non-interactively?

I am writing a pre-commit hook to update version number and sync that up in a couple of files. These files absolutely cannot import version from the main version file.

I can already change and sync version numbers in all the files. However a couple of files contain other data too and I want to add only the lines with version info automatically to git in pre-commit.

I can get those line numbers. Is there a command/option/way to add those lines to git non-interactively? Because the pre-commit hook can of-course not be interactive.

Update: Looks like it has been already asked at stackoverflow.com/q/2783166 for anyone who happens to stumble on my question.

Akash
  • 5,153
  • 3
  • 26
  • 42

0 Answers0