What does this do: git branch -f

2020-06-08 07:20发布

问题:

I'm trying to figure out how to use this command properly. I believe this is the command and flag I want to essentially make one branch into my other branch (basically delete a branch and create a new branch with the same name with the files of another branch), but I don't know for sure, or if I have the syntax correct.

If I do this:

git branch -f master sub-branch

Will it remove all of the files from master and fill it with the files from sub-branch?

回答1:

The -f argument stands for --force.

  • If a branch called master already exists, git will not allow you to overwrite it, unless you use -f.
  • Second parameter (sub-branch) will be used to determine where the master branch's HEAD should be pointing to.


标签: git branch