how do I then make a commit without affecting the git blame
You can get pretty darn close, I'd think compensating for the hand modifications won't be worth the pain, but ignoring automatic-reformatting changes is easy: git blame
applies any text conversions you specify to the file contents, so tell it to run a prepass with your linter in full-auto mode before it inspects the results for blameworthy changes.
Here's a test case where the "style linter" just adds "REFORMATTED" as the first word of the second line. and git is instructed to regard that as not blameworthy by running (an idempotent version of) it as the text conversion.
cd into a trash directory and copy this into file temp
inside,
find ! -name temp -delete; git init
doit() { eval "$@"; shift $(($#-1)); git add .; git commit -m "$*"; }
(
doit '>file'
doit echo '>>file' line1
doit echo '>>file' line2
doit '>B'
doit sed -i "'s/line2/REFORMATTED line2/'" file '#' 'REFORMATTED line2'
doit echo '>>file' line3
) >/dev/null
set -x
git log --oneline --graph --decorate
git blame file
git config diff.REF.textconv 'awk '\''NR==2 && $1!="REFORMATTED" {$1="REFORMATTED "$1 }1'\'
mkdir .git/info
echo file diff=REF >.git/info/attributes
git blame file
then do sh temp
. Your metadata will change 'cause timestamps and ids, but otherwise you should see
$ sh temp
Initialized empty Git repository in /home/jthill/src/snips/test/.git/
+ git log --oneline --graph --decorate
* 282c142 (HEAD -> master) line3
* ee58923 REFORMATTED line2
* d8558d2 >B
* 6801a1d line2
* 030e551 line1
* f912c83 >file
+ git blame file
030e5517 (jthill 2019-02-23 18:41:36 -0800 1) line1
ee589239 (jthill 2019-02-23 18:41:36 -0800 2) REFORMATTED line2
282c142d (jthill 2019-02-23 18:41:36 -0800 3) line3
+ git config diff.REF.textconv 'awk '\''NR==2 && $1!="REFORMATTED" {$1="REFORMATTED "$1 }1'\'''
+ mkdir .git/info
+ echo file diff=REF
+ git blame file
030e5517 (jthill 2019-02-23 18:41:36 -0800 1) line1
6801a1d6 (jthill 2019-02-23 18:41:36 -0800 2) REFORMATTED line2
282c142d (jthill 2019-02-23 18:41:36 -0800 3) line3
... notice in particular the change in the blame for line2.