What I did was echoing a control sequences which searches for the regex isPhoneGap during an interactive reset process. If ] thenĮcho there are no actual changes to be commited and besides the change to the variable \'isPhoneGap\' so I won\'t commit. # BONUS: Check if after reseting, there is no actual changes to be commited and if so, exit 1 so the commit process will abort. This \`pre-commit\` hook will reset all the files containing this line to it's previous state in the last commit.Įcho /$'\n'isPhoneGap$'\n'y$'\n'q | git reset -p WARNING: You are attempting to commit changes which are not supposed to be commited according to this \`pre-commit\` hook # this hook looks for lines with the text `var isPhoneGap = false ` in the file `buildVars.java` and it resets these lines to the previous state before staged with `reset -p` The hook script looked like this when I tested it on my machine. I'm not sure this hook will work for a situation where you have many files with this line to be ignored, but this pre-commit hook looks for a changed in this line in a specific file buildVars.java. Inspired by answer, I found myself using perhaps an improved version of his hook which automatically resets (with the -p flag) the specific line which we want to ignore. ![]() If so, it echos a warning and it exit's with code 1 so the commit process won't continue. ![]() The hook checks if those lines were staged. Continuing, proposed to create a pre-commit hook which will grep in the staged files for the lines which one might want to ignore.
0 Comments
Leave a Reply. |