What is the difference between --force and --force-with-lease in git?

4

In git when doing a push if the local and remote branches do not agree, it is necessary to do a force push (although it is not well seen to do a force push ). In git there are two options for this option --force and option --force-with-lease .

By the name it seems that --force-with-lease is less aggressive or does not always push but I would like to know what is the difference between these two options.

Ex: git push origin master --foce vs git push origin master --force-with-lease

    
asked by Daniel Pérez 19.06.2017 в 16:22
source

1 answer

5

Git push --force is destructive because it unconditionally overwrites the remote repository with whatever it has locally, possibly overwriting any changes that a team member has pushed, which can erase any member's changes. However there is a better way the option --force-with-lease which is the best recommended can help when you need to do a forced push but still make sure not to overwrite the work of others.

    
answered by 19.06.2017 / 17:08
source