Git version: 1.7.12.3
As the question states, that seems like a really bad idea to me. Without any additional flags or confirmations git push -f will force push all of the tracking branches to remote.
If a developer has a few outdated branches, that are tracking remotes, and he executes that command, all of the tracking branches will have been rolled back to his outdated copies, which causes loss of valuable work.
This can be done accidentally, or by someone not very experienced with git. It really seems like git should do a little more hand-holding in such a dangerous case, and require an additional flag, or ask for a confirmation.
Is there a remedy for this?
Since it's January, 2016 now, I guess it's worth to add some updated info to this question:
git push --force behaves exactly like normal git push in terms of pushing current or all the changed branches.git push pushes either all branches or a single one dependent on this configuration of the push.default
.gitconfig should looks like:
[user]
name = User Name
email = [email protected]
[push]
default = simple
.gitconfig in Unix-like OS just do cat ~/.gitconfig. This post shows to how to do this on Windows.simple mode) become default only in Git 2.0 (released on 2014-12-17). 1.7 (or who has updated from 1.7), has matching mode as default mode (pushing all the branches).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With