使用git branch -f或git update-ref来快速提供现有分支会更好吗? [英] Is it better to use git branch -f or git update-ref to fast-forware existing branch?
问题描述
我意识到我可以使用 git update-ref
来快进我不在的现有分支。然后我发现类似的东西可以通过 git branch -f
来完成。我知道 git update-ref
更加灵活(它可以移动任何ref),但它可能是危险的。那么使用 git branch -f
会更好吗?这两个命令在这些特定场景中是否有区别? (除此之外,我可以指定自定义ref日志消息。)
使用 git branch -f
,它会拒绝更新分支,如果它是(如果它是当前分支)
git update-ref
没有这个限制。 Qqwy 增加了另一个区别在评论 a>: I have realized that I can use With Qqwy adds another difference in the comments: 这篇关于使用git branch -f或git update-ref来快速提供现有分支会更好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
git分支-f< branchname>如果它不存在,[< / lt; start-point>]
将创建一个名为< branchname>
的新分支。
git update-ref< branchname> < newvalue>
在这种情况下不会执行任何操作。
git update-ref
to fast-forward existing branch that I am not on. Then I have found that similar thing can be done by git branch -f
. I understand that git update-ref
is much more flexible (it can move any ref), however it could be dangerous. So is it better to use git branch -f
? Are there any differences in these two commands in this particular scenarios? (Except of that I can specify custom ref log message.)git branch -f
, it would refuse to update the branch if it is the one checked out (so if it is the "current branch")git update-ref
has not that limitation.
git branch -f <branchname> [<start-point>]
will create a new branch called <branchname>
if it did not exist. git update-ref <branchname> <newvalue>
will do nothing in this case.