how to close a branch in git

When I know I won’t use a branch any more is it possible to close or lock it? Actually I would like to close a branch but I don’t think it is possible to close a branch with GIT. what about the delete. What happens to my history when I delete a branch?

  • replace git submodule protocol from git to http
  • Develping with Django, Git, and Cloud Server
  • What is Git and why do I want it?
  • Gulp - Get return value of one task from another
  • Allow access to git repository from a certain commit
  • How can I install pybrain module?
  • Git commit unknown Author
  • Can I use a GIT repository with SVN clients?
  • Executing 'git pull' from SSH in Dreamhost to GitHub without password
  • What is HEAD in Git?
  • How to handle tracked generated files in git?
  • Create a branch alias and push it
  • 3 Solutions collect form web for “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>
    

    If you want to delete a branch completely, you can just delete it in all your repositories (typically local and remote). git will then clean it up next time it garbage collects.

    See How do I delete a Git branch both locally and remotely? for instructions.

    you can refer to git finding unmerged branches to find those branch that have been merged or not.

    If a branch has been merged into other branch, it is safe to delete it use the follwing command.

    git branch -D branch_name

    Git Baby is a git and github fan, let's start git clone.