What happens in the child branch if I delete a parent branch in git

前端 未结 2 358
失恋的感觉
失恋的感觉 2021-02-05 08:23

I am planning to rename a branch in my git repository. I found out that the easy way to do that is to make a new branch from that branch and give it the desired name.

A

2条回答
  •  滥情空心
    2021-02-05 09:22

    What happens? nothing.

    If you create a branch where another is, you can "delete" that other branch without losing anything. A branch (HEAD) is just a pointer to a commit.
    As long as those commits are referenced by a branch HEAD (or are part of the branch HEAD ancestors), they aren't lost.
    And even if they are no longer referenced by any branch or tag, they are still in the local reflog for (by default) 90 days.

    But, looking at the man page for git branch, this seems easier:

     git branch (-m | -M) [] 
    

    With:

    -m
    --move
    

    Move/rename a branch and the corresponding reflog.

    -M
    

    Move/rename a branch even if the new branch name already exists.

提交回复
热议问题