Git branch deletion

前端 未结 4 2140
情歌与酒
情歌与酒 2021-01-29 19:22

In Git, what does \"deletion\" of a branch mean?

Will it be gone from the repository? Or will it still be navigable to via git branch?

What I reall

4条回答
  •  温柔的废话
    2021-01-29 20:16

    Git branches are stored as references to a revision. If you delete the branch, the reference is removed; if nothing else references that revision, it will eventually be garbage collected. Also, if you delete the branch then it's properly gone (from your repository). If you want to mark a branch as deprecated but keep it around for later use, you could move the branch to a subdirectory:

    $ git branch
    * master
      testing_feature_one
      testing_feature_two
    $ git branch -m testing_feature_one deprecated/testing_feature_one
    $ git branch
      deprecated/testing_feature_one
    * master
      testing_feature_two
    

    Alternatively, you could create a separate repository for deprecated branches, pull them across then delete them from the original. In either case, you're going to affect any users who are following the branches -- the content of their repository won't change (and neither will any of their branch names), but if they try to pull again, they'll have to change their target in their configuration.

提交回复
热议问题