1

I created a local branch with an apostrophe in its name (the name is Bug/1243-sth-sth-don't-show).

After I switched to a different branch I haven't been able checkout the above branch as it shows that it can not find it.

I've tried to avoid that apostrophe, but it doesn't work and a Google search indicated that it may a bug in GitHub, but the issue has been closed.

I'm uncertain how to proceed, any help is appreciated.

AbsoluteSpace
  • 710
  • 2
  • 11
  • 21
Ping Woo
  • 1,423
  • 15
  • 21
  • 5
    By "comma", I believe you mean "single quote" or "apostrophe" – William Pursell Jul 11 '19 at 02:25
  • 1
    I suspect your problems are merely shell quoting issues. The following works fine to create a branch with a single quote in the name, checks it out, and then creates a new branch at the same commit: `git branch "badly-named-'-branch"; git checkout "badly-named-'-branch"; git branch better-name` – William Pursell Jul 11 '19 at 02:28

2 Answers2

2

You can combine the two approaches (mine with --, and quotes), using the git branch rename command.

git branch -m -- "old-name-with'-quote" "new-name"

(note: "'" is not a comma but a single quote)

Other approach:

git checkout {hash}
git checkout -b new-name
git branch -d -- "old-'-name"
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

You might find this answer helpful as it mentions that you can do something like git checkout -- Bug/1243-sth-sth-don't-show since the -- will treat all following arguments literally.

AbsoluteSpace
  • 710
  • 2
  • 11
  • 21