DEV Community

Discussion on: Git Concepts I Wish I Knew Years Ago

Collapse
 
jnareb profile image
Jakub Narębski

A few things. First, do not use git branch for scripting, as it is meant to be user-facing command which output format can change and which is subject to config, but git for-each-ref explicitly meant for scripting.

Second, instead of git push --force, use safer alternative of git push --force-with-lease which would overwrite only your changes.

Third, git restore might be easier to use than git reset.