LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   General (http://www.linuxquestions.org/questions/general-10/)
-   -   How to Git delete a branch? (http://www.linuxquestions.org/questions/general-10/how-to-git-delete-a-branch-4175446144/)

binladen_vn88 01-18-2013 03:37 AM

How to Git delete a branch?
 
I have learned when create a branch, Git will create a pointer point to a commit ID.
I create "test" branch based on "master" branch
Code:

C1 <- C2 <- C3 <- master
            `<- test

After some commit ID:
Code:

C1 <- C2 <- C3 <- C6 <- master
            `<- C4 <- C5 <- test

And now, i want to delete "test" branch using command below:
Code:

$ git branch -d test
Git will delete only current commit ID "C5" or delete both "C4" and "C5".
I really don't know how to git delete "test" branch?
Please explain for me.
Thank so much!

konsolebox 01-18-2013 06:00 AM

Use -D perhaps.
Code:

git branch -D test

sundialsvcs 01-18-2013 08:19 AM

And, IIRC, even that is just another "commit." With Git, nothing ever truly goes away.

ntubski 01-18-2013 09:39 AM

Quote:

Originally Posted by sundialsvcs (Post 4872888)
And, IIRC, even that is just another "commit." With Git, nothing ever truly goes away.

The branch's previous state is saved in the reflog, but it's not the same as other commits. Deleting test in this example leaves C4 and C5 as unreachable (except via the reflog) commits. If you run git gc after the reflogs pointing to those commits have expired (default 90 days) they will truly go away.

binladen_vn88 01-21-2013 12:55 AM

Quote:

Originally Posted by ntubski (Post 4872937)
The branch's previous state is saved in the reflog, but it's not the same as other commits. Deleting test in this example leaves C4 and C5 as unreachable (except via the reflog) commits. If you run git gc after the reflogs pointing to those commits have expired (default 90 days) they will truly go away.

Thank so much, it is really thing i want to know, ^_^


All times are GMT -5. The time now is 11:19 AM.