1

TLDR: how to git add --patch yarn.lock after various dependency changes?

Okay, this might be my sometimes messy workflow but I want to know all possible options before deciding if that's actually true 😉

So I really like to sometimes rapidly move forward and then git add --patch my changes in contextual chunks/hunks as I see fit when I feel it's time to version my mess, and I prefer git add --patch recently anyway as I get to see my changes one by one while deciding consciously… Only problem I came across so far is yarn.lock (I guess package-lock.json might be the same).

To get to the point, after messing around, changing various things, installing/removing dependencies, I decide e.g. one of those changes gets to be "official" now, I can easily pick all the desired changes related to this. But at this stage I might have installed/removed multiple dependencies, so yarn.lock has changed a lot and, contrary to package.json, I can't safely and easily pick just the updates I care about. Not without checking all changed packages in detail and figuring out their dependencies. Or am I missing something?

Based on this issue using git checkout -- yarn.lock could be a way, so I would check out a former yarn.lock, but I would have to at least temporarily undo changes to package.json, than do my yarn add/remove .. so yarn.lock updates correctly, git everything, then redo my package.json/yarn.lock changes and continue my work.

Any other ways/proposals?

0

Your Answer

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

Browse other questions tagged or ask your own question.