Search code examples
gitversion-controldvcs

Git branch -f versus soft reset


Does the GIT command:

git branch -f master master^

have the same effect as:

git reset --soft master^

Is it so?


Solution

  • Theoretically yes, practically no. The first option does not work if master is your current branch. You cannot force-update the current branch with the branch command.

    Should you be on another branch, then they are not identical either:

    • the first option moves back the master branch and leaves your current branch alone
    • the second option moves your current branch to the one before master, and leaves master alone.