[ad_1]
For a personal project, I started on code changes, then realized I needed something more complex, so I didn’t commit them and did other things.
Two hours later I had an idea to make a big sweeping change. In this case, it was replacing the word “touchable” with “fungible” in Inform 7, to speed things up. So I made the change quickly, not stashing the current code. (Yes, this is an error in process. But it’s one that will happen again.)
The problem was, there were 250 chunks in one file that the text was changed and only one or two chunks related to the changes I’d started working on. And I wanted to commit the 250 without the 2.
This wasn’t painful once I tracked the line numbers (9100 to 9200) and used git add --patch story.ni
to verify changes until the critical sector. I typed y
quickly until I got to line 8800. Then I slowed down and typed a
to add the rest.
I suppose I could also have cut the file down to 9100 lines, added, undid the truncation, and type n
then a. But I’m not looking for tricks. I’m looking to become more confident with the inner workings of git, e.g. if there are command line arguments that would clean this up e.g.
git add --linechunk:1-9100 --linechunk:9200-30000
Or…
git add --linechunk:-9100 --linechunk:9200
Though my method was good enough, knowing if there’s a way to do more than manually patch things would be neat.
For those more agile with git, is there a way to do be more efficient?
[ad_2]