3 ms·
please don't "git push --force" unless you know what it's doing, people - you will lose work and people will get really confused. the --force should never be n
by schacon 17y ago
please don't "git push --force" unless you know what it's doing, people - you will lose work and people will get really confused. the --force should never be necessary, even when using 'pull --rebase'. the push command normally will refuse to push unless the latest commit on the server is in your history somewhere. this means that if someone pushes since you last pushed or fetched, introducing commits you have not seen yet, and you try to push, it will not let you until you have pulled them down and either rebased your local work on top of it or merged your work with it.
'--force' overrides this check, pushing anyways, effectively losing (possibly multiple) commits on the server. it should only be used if you were forced to change your history somehow (removing files with a password in it, rewinding work in an emergency), it should almost never be used and there should be a really good reason for it. i've used it maybe a dozen times last year of the thousands of pushes i've done.
- jrockway 17y agoI liberally rewrite my history; this is why I push --force. I don't view version control as an auditing tool, I view it as a debugging tool. YMMV.
- schacon 17y agoif you are the _only_ person with push access to your repo, then that's fine. i just don't want other people reading this that collaborate with people on repos that multiple devs have push access to thinking that --force is fine to use, because it will lose commit data.