tags:

views:

181

answers:

4

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 really want to do is mark a branch as DEAD END, i.e. the branch is so far from master, that nobody should use it as a starting point, though there were some good ideas down that branch, so we'd like to keep it, for reference.

A: 

git branch -D branchName will detele your branch from repository. You will not be able to see it or navigate anymore..Also you will loose all file changes made in that branch.

http://ftp.sunet.se/pub/Linux/kernel.org/software/scm/git/docs/git-branch.html

Stewie Griffin
+1  A: 

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.

Andrew Aylett
A: 

It won't be navigable via git branch and until garbage collection is performed, it won't be lost from the repository.

If you want to mark the branch in question as a dead end then simply do so (git may not do this for you but you certainly can)!

Labelling it (in any way you prefer) as a historical reference works.

Fake Code Monkey Rashid
+4  A: 

You can delete the branch, but tag it first, so that it's history doesn't disappear. This way, the branch doesn't show up in the branch list, which should hopefully deter people from working on it, but the work won't be permanently erased (even after garbage collection is run).

While on master or some other branch:

git tag foo-dead-end foo
git branch -D foo

This creates a tag named foo-dead-end from the foo branch before deleting foo. You can also add a message to the tag, that explains what is in the branch, why it existed, why it's now a dead end, etc.

git tag -m 'Foo is deprecated in favor of bar' foo-dead-end foo

This is perhaps an advantage of tagging dead branches versus moving them to an alternate namespace. Although you could even do both (tag branches and then move them) if you really wanted.

Dan Moulding