Search code examples
gitgit-branchgit-remote

How to see all past branches in the git remote?


I would like to list all branches, even those what already removed in a remote (origin). The main point that I would like to see event the removed ones

It would be OK just to see branch the names, but ideally the creation date and some other metainfo would be great like user name who created the branch.

I've found many related Q and A but neither lists the already removed branches. I am a newbie in git, so I do not know even is this possible, but I hope.


Solution

  • GIT branches are just lightweight pointers on a graph. They don't "contain" anything, they just point to a commit (a commit hash to be precise). There is nothing to stop you just moving (reset) a branch to any point on the graph. So the idea of meta data doesn't make sense. Think of a branch as a label and a commit hash and that's it.

    When a branch is deleted, it's deleted. There is no getting it back. All the commit's still exist but the label and hash are no longer stored in the file system. You can recover deleted branches. This is only in the sense that you can add a new pointer to any disconnected commits though. The original branch is still deleted, your just replacing it with a new branch that happens to have the same name.

    If you want to add meta data to a GIT repo then I'd suggets you use tags. You can then add meta data at certain points in the graph: enter image description here

    So above you can see I've added tags (blue) that show when certain builds happened. So you could add a tag everytime you create a branch and where that branch was created, who created it, etc.