4 ms·
--force always imply data loss. You're overriding the remote state. Do people use it in an unsafe manner because they don't understand git and there lies a pro
by guax 3y ago
--force always imply data loss. You're overriding the remote state.
Do people use it in an unsafe manner because they don't understand git and there lies a problem that could be tackled? yes.
With that, I don't think git has any feature that is unsafe by default.
- sasham 3y agoIn that specific case there was some error that the user didn't understand, he googled and found a StackOverflow answer with --force. And naturally tried it BitBucket didn't have branch protection back then, today it's a bit better (you can still destroy your work but usually not others')
- nullstyle 3y agoThis was Pebcac my dude. git wasn’t at fault here, the script kiddy that pastes before understanding is the fault. Amateurs
- Einenlum 3y agoI agree that git is very complex (just try reading its documentation and how many options or commands you have never heard of before). But I think push --force is probably one of the easiest git concepts to get. The fact that someone in your team copy pasted something from SO without understanding it doesn't seem to be related to git. Otherwise we could say that the fact some people lose their data through "sudo rm -rf /" proves the complexity of Unix. I don't think so.
- IshKebab 3y ago> With that, I don't think git has any feature that is unsafe by default. Well, you just mentioned `--force`. It is unsafe by default. Git has a couple of flags to make it safer (`--force-with-lease`, `--force-if-includes`) but those aren't the default.
- withinboredom 3y agoIf you’ve ever had to remove private information from history before making the repos public (think domains, names, configuration, etc) you will appreciate the ability to rewrite history (and all the other things --force gives you)
- IshKebab 3y agoI don't get your point. Nobody is saying don't use `--force`. Just that the default `--force` flag is the most dangerous variant.
- withinboredom 3y agoI am not aware of any default use of force. Where does that happen?
- kristjansson 3y agoThe feature is 'git push'. --force is the opt-in to the unsafe behavior. It should not be used lightly.
- IshKebab 3y agoYou're missing the point. `--force` is the default of the force variants. The other `--force-but-something` arguments clearly modify that default. It's the wrong way round. Obviously they've done it for backwards compatibility, but the fact that they haven't even added an option to make it the default is pretty lame.
- CJefferson 3y agoMy biggest problem with git is branch deletion — if you never do it you end up with far too many, but deleting a branch can’t be version controlled.
- AdityaSanthosh 3y agoJust curious, why do you want that to be version controlled?
- CJefferson 3y agoBecause I might realize later I made a mistake, or I might want to view history. I’d I never cared about historical state and mistakes, I wouldn’t need version control at all :)
- couchand 3y agoYou could delete the branches locally while archiving them to any another clone of the repo.
- renewiltord 3y agoIt is somewhat version-controlled but not completely. If you use the reflog you can find it again and you can find how it moved around. But the reflog gets rewritten and gc'd so it's not true vc.