1

I am new to git so please forgive my ignorance. I had to delete some folders from several of my branches but now it looks like a mess see below. I have branches with ~2 ^ etc. I do not understand what they are and how to get rid of them Any help would me most appreciated.

xxxxxxxxxxxx:/var/www/installation$ git show-branch
! [demotracking] delete a few folders _notes
 * [master] delete a few folders _notes
  ! [newexport] delete a few folders _notes
---
  + [newexport] delete a few folders _notes
  + [newexport^] Finish report may still need to modify
 *  [master] delete a few folders _notes
 *  [master^] Misc fixes and added Demo Tracker to header file
+   [demotracking] delete a few folders _notes
+   [demotracking^] delete a few folders
+   [demotracking~2] delete installtion and installationdev folders
+*  [master~2] Minor updates to devices.php and listpos.php
+*+ [newexport~2] Changed sort on PO Status
bmargulies
  • 97,814
  • 39
  • 186
  • 310
  • https://stackoverflow.com/questions/2221658/whats-the-difference-between-head-and-head-in-git should help a bit. The annotations relate the branch to your HEAD. –  Mar 05 '18 at 05:08
  • If you want to get rid of a branch, you can force it with `git branch -D `. –  Mar 05 '18 at 05:09
  • I see all these docs they tell me what they are and that is great thanks you but I do not see anywhere what I need to do with them or even if I need to do anything. I cannot seem to delete them I tried git branch -D demotracking~2 but I am assuming I can only delete branch -D demotracking like this which I do not want to do. – Rick Venuto Mar 05 '18 at 05:48
  • Correct, it would only delete the complete branch. The separate `~...` indicators just refer to specific commits in that branch. You could only get rid of them by removing that commit (or squashing/rebasing), but that seems inadvisable. But otherwise: they don't hurt. There is no need to get rid of them if you don't want to remove the branch. –  Mar 05 '18 at 06:44
  • Thank you that is what I wanted to know. – Rick Venuto Mar 05 '18 at 15:49

2 Answers2

1

See the reference on git revision syntax.

The other main ancestry specification is the ~ (tilde). This also refers to the first parent, so HEAD~ and HEAD^ are equivalent. The difference becomes apparent when you specify a number. HEAD~2 means “the first parent of the first parent,” or “the grandparent” — it traverses the first parents the number of times you specify.

bmargulies
  • 97,814
  • 39
  • 186
  • 310
1

You might be interested in the documentation about the output of git show-branch. This isn't actually showing you that you have multiple branches with odd names... Rather, it's showing that the sequence of commits on your branches look like this: graphviz of commits

Squares in this diagram being commits that are also the heads of each of the branches, ovals being commits with no explicit branch pointer to them, at least not that's being considered right now. As it takes a few commits of history on each branch before reaching a common commit between all three of these branches, git is using relative references to show you this structure on the command line. (It's also showing you that master is the currently checked out branch but that's another matter).

You do not need to do anything, however, if you wanted to clean up your history a bit I would look into rebasing your demotracking and newexport branches on top of your master branch so that you have the deletion commits, and then the other branches can build upon this.

Charlie
  • 7,181
  • 1
  • 35
  • 49
  • Did you have a go with a drawing program, or is there a tool for creating that graph? I'd assume the latter, but then you'd have to mimic the OP's situation first to use that. So is the answer to my question perhaps: yes, yes? –  Mar 05 '18 at 06:43
  • In this case, it's just [graphviz](https://en.wikipedia.org/wiki/Graphviz). I leveraged [a web version of it](http://www.webgraphviz.com/) to quickly throw together & render OP's situation... (no git involved if that's what you're hoping for, but I have previously seen projects that have done git -> graphviz visualizations) – Charlie Mar 05 '18 at 06:56