Is it better to use git branch -f or git update-ref to quickly develop an existing branch?

I realized that I can use git update-ref to quickly forward an existing branch that I am not . Then I discovered that this can be done with git branch -f . I understand that git update-ref much more flexible (it can move any links), however this can be dangerous . So is it better to use git branch -f ? Are there differences between the two teams in these specific scenarios? (Except that I can specify a custom message log message.)

+1
git
source share
1 answer

With git branch -f , it will refuse to update the branch if it is selected (so if it is the "current" branch ")

git update-ref has no such limitation.


Qqwy adds another difference in the comments :

  • git branch -f <branchname> [<start-point>] will create a new branch named <branchname> if it does not exist.
  • git update-ref <branchname> <newvalue> will not do anything in this case.
+2
source share

All Articles