how to close a branch in git

Updated Answer

As @user3159253 stated in comments of this answer :

git garbage-collects commits which aren’t referenced, directly or indirectly, by a named reference (branch, tag, etc). That is why it is important to leave a reference to a freezed branch.


You can tag the tip of the branch by archiving it, and then delete the branch.

git tag archive/<branchname> <branchname>
git branch -d <branchname>
git checkout master

The branch will be deleted, and can be retrieved later by checking out the tag, and recreating the branch.

git checkout archive/<branchname>
git checkout -b new_branch_name

Or more simply :

git checkout -b new_branch_name archive/<branchname>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)