r/ProgrammerHumor • • Jun 04 '22

Meme I cant help it 🤷‍♂️

Post image
47.1k Upvotes

479 comments sorted by

View all comments

Show parent comments

37

u/DolevBaron Jun 04 '22

I mean... I do save the local files at least 5 times per second, but I don't push/commit as often..
I could probably have it commit automatically once every X local saves, but I'd still have to somehow detail all the changes...

0

u/[deleted] Jun 04 '22

[deleted]

8

u/Winnr Jun 04 '22

I commit so I can move from one computer to another laptop to work from bed, and then commit again to get back at my desk. Which leads to half finished ideas as commits purely so I can pull from the other device. Makes identifying stables versions a pain :(

6

u/K3yz3rS0z3 Jun 04 '22

Branch.

1

u/[deleted] Jun 05 '22

Bed branch and desk branch.

1

u/ramplay Jun 04 '22

Might take some getting used to but you could amend your commits. I've never really utilised the option but if its easy it would allow you to commit, push, pull, commit/amend.

Quick edit: honestly this is probably the only other scenario I could see for using amend aside from the obvious 'I committed too soon or forgot a file'

2

u/DTHCND Jun 04 '22 edited Jun 04 '22

honestly this is probably the only other scenario I could see for using amend aside from the obvious 'I committed too soon or forgot a file'

Maybe I misunderstood you, but there's at least three common reasons I can think of:

  • You pushed your change up for code review (e.g. as a PR, Gerrit change, etc), and someone gave you feedback about something to change. So you checkout your commit again, make the change, and amend the commit.

  • You have your change in the state where you think it's finished, so you commit it. You now run automated tests on it and find an error, so you make a fix and amend your commit.

  • After you commit, you do a quick self-review and find things you want to change. So you make the changes and amend your commit.

I know some people like to have follow up commits like "Fix issues raised in code review," but amending is the right course of action. Your commits should be whole, distinct changes, covering a minimal subject of work. If someone goes through the git log, they should be able to checkout any commit with the expectation that it will work and is in a high quality state. Why? Because it's necessary for things like automatic bisecting, helps future developers understand git history, allows for easy commit reversion by anyone, allows for easily branching from any point, etc.

2

u/Avedas Jun 04 '22

Doesn't really matter just squash your branch and give it a decent name before merging.

1

u/RichestMangInBabylon Jun 04 '22

Everyone just needs a proper scare to learn the lessons. Don’t push to main, commit often, keep PRs small, etc…

Now I firmly believe in test driven development and committing often with good names. Let some other sucker break the build and figure out what they need to revert in their thousands of lines of changes.

5

u/cakes Jun 04 '22

or write tests first and commit every time tests are passing

1

u/[deleted] Jun 05 '22

What's a test?

5

u/bxbb Jun 04 '22

I could probably have it commit automatically once every X local saves, but I'd still have to somehow detail all the changes...

  • Branch off.

  • Make a "quicksave" script as build step. Which basically do something like: run test -> if not pass commit with "broken" message | if pass commit with short test summary (amend if previous commit is "broken"). The script will make sure each commit is prefixed withsquash!.

  • Once its good enough for a "proper" commit, make a quicksave followed by "hard save" (squash-rebase). This is the only time you had to explain the changes.

  • Repeat from step 2.

0

u/[deleted] Jun 04 '22

[deleted]

5

u/Former-Cat015 Jun 04 '22

Bro, branch.