7
submitted 1 week ago by [email protected] to c/[email protected]
top 8 comments
sorted by: hot top controversial new old
[-] [email protected] 8 points 1 week ago

If you’re using reset with uncommitted changes and you’re not intentionally throwing them away, you’re doing something wrong. git reset —hard means “fuck everything, set the state to X”. I only ever use it when I want to throw away the current state.

[-] [email protected] 4 points 1 week ago

Well yeah I think the point is you're human and you might make a mistake.

[-] [email protected] 6 points 1 week ago

Using git reset --keep would just make more work since I'll have to throw away uncommitted changes anyways. Removing uncommitted changes is kind of the whole point, it is called 'reset' after all. If I want to preserve uncommitted changes, I'll either stash them or commit them to a temporary branch. That has the added benefit of adding those changes to the reflog so if I screw up later I'll be able to recover them.

[-] [email protected] 4 points 1 week ago

Let me live with my mistakes

[-] [email protected] 0 points 1 week ago* (last edited 1 week ago)

~~Waddyamean "that's what backups are for"~~ Sorry, wrong community

[-] [email protected] 3 points 1 week ago

Not many people back up continuously, so this is still useful.

[-] [email protected] 4 points 1 week ago

I do not actually understand the use case of —keep over the default —mixed, which I use regularly to restage patches or fuckups. I very frequently use —hard to test something out and blow it away without worrying about any changes. This whole conversation is fascinating because it highlights just how different everyone uses git and equally how bad sweeping generalizations like “—hard is something to avoid” are (without incredibly specific caveats).

It seems like —keep makes sense if you’re not using stash before trying to change history when you have local, uncommitted changes? That might be why it’s not clicking with me; any time I fuck with history I stash anything local I might want to keep.

[-] [email protected] 2 points 1 week ago

This is great advice. I did not know that '--keep' was an option, and have offen done rather lengthy work arounds to achieve this.

this post was submitted on 02 Sep 2024
7 points (88.9% liked)

Git

2825 readers
33 users here now

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Resources

Rules

  1. Follow programming.dev rules
  2. Be excellent to each other, no hostility towards users for any reason
  3. No spam of tools/companies/advertisements. It’s OK to post your own stuff part of the time, but the primary use of the community should not be self-promotion.

Git Logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.

founded 1 year ago
MODERATORS