Live data from Hacker News

How to commit part of file in Git

newbeelearn.com

11–20 of 104 posts

Re: How to commit part of file in Git

#12
post #3

The only sane way to do this is with a proper IDE. Doing it via the command line is pure masochism.

I do hg split (which I think this is based on? Or at least it's very similar) all the time and it's fine. I guess an IDE makes it a little easier to select regions that don't line up with hunks?

Re: How to commit part of file in Git

#13

Splitting up commits is totally underrated and seen rarely. I see colleagues over and over again plumbing 4 kinds of changes into the same commit. Good luck reverting the one change that caused an outage.

People will actually revert commits? For real? At work? Where do I get to sign up?

Re: How to commit part of file in Git

#15
post #5
post #3

The only sane way to do this is with a proper IDE. Doing it via the command line is pure masochism.

Why? I use git add -p absolutely all the time, its really simple to learn

I use `git add -p` regardless if the whole file gets committed or not since I use it as a visual review tool to verify what I've changed.

Re: How to commit part of file in Git

#17
post #13

Splitting up commits is totally underrated and seen rarely. I see colleagues over and over again plumbing 4 kinds of changes into the same commit. Good luck reverting the one change that caused an outage.

People will actually revert commits? For real? At work? Where do I get to sign up?

Relatively common practice where I work. What do you do instead?

Re: How to commit part of file in Git

#18
post #13

Earlier quoted context omitted.

People will actually revert commits? For real? At work? Where do I get to sign up?

Relatively common practice where I work. What do you do instead?

Not the GP but we tend to use decently small and meaningful commits to make PRs easier to review. They then get squashed, so you can only (easily) revert the whole PR.

Re: How to commit part of file in Git

#20

I've used tig to do this for 15+ years. It's effortless. I know lazygit is more modern and has more features, but tig does this so well I have no need to change.

I kept running into an issue with tig where it couldn't break apart a hunk, or otherwise couldn't stage a part of one. I never figured it out by the time I gave lazygit a shot. Now that I've used lg in anger I only wish I had invested in it sooner.
Post reply on HN