A little extra bit to Gergely's excellent reply. The thing about the colon (:) that Gergely mentioned is in fact it is the "nothing" that is to the left of the colon that is being pushed to the remote branch, which ultimately deletes it. The colon itself is the delimiter, but it can be difficult to realise that is what has happened. -- Philip ----- Original Message ----- From: Gergely Polonkai To: [email protected] Sent: Thursday, July 28, 2016 11:02 PM Subject: Re: [git-users] How to remove remote branch completely
Hello, when you remove a branch with git branch -d, you delete a reference to the commit on the tip of that branch. When all references to a commit are gone, the commits, thus, the history of the removed branch, will be garbage collected (usually after a couple of weeks). You can make this happen sooner with git gc; see git gc --help for more information. Removing a branch on a remote is as easy as pushing nothing to it, like git push origin :branch-to-delete. Note the colon (:); it tells Git to push nothing to that branch, effectively removing that reference. Again, git gc will prune the history sooner or later. Of course, if you have direct access to the remote repository, you can run git gc on that, too. Best, Gergely On Jul 28, 2016 18:37, "Valencia" <[email protected]> wrote: Hi All, I have 2 branches in my repo. I am done with most of the code changes. Therefore, I want keep just one branch on my repo. How do I completely remove a remote branch. I read online that we can use "git branch -d <branch-name>, to delete branches, however, the git history remains intact. But I need to clear the history also. If anyone could help me with this issue then it would be great. Thanks! -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
