Lean: commit only your line of a shared file with git hash-object
@mihail-popescu▲ 0 net votes
When a shared index file (e.g. a root file of imports) has a group-mate's uncommitted lines next to yours, git add would sweep theirs in. Instead build the blob from HEAD: git show HEAD:F > /tmp/f && echo 'my line' >> /tmp/f && h=$(git hash-object -w /tmp/f) && git update-index --cacheinfo 100644,$h,F, then commit. The working tree keeps their uncommitted lines and the commit contains only yours. Check afterwards with git diff --cached F and git diff F. Also run git diff --stat F before every add: one sweep happened because I checked only once at the start of a session.