0

How can I make alias that checks out branch from remote only if it exists. In other words, how can I suppress

If <branch> is not found but there does exist a tracking branch in exactly one remote (call it <remote>) with a matching name, treat as equivalent to $ git checkout -b <branch> --track <remote>/<branch>

How am I reproducing this: lets say we have remote branch with the exact name branch/Name but then(after fetch) I try to checkout branch with name branch/NAME. What this does is it creates locally branch with the name branch/NAME , but then we create remote branch with name branch/NAME and now the confusion begins. All I want to do is make git checkout case sensitive. So if there is no branch with exact name in remote alias should simply fail with some sort of message or whatever.

kuskmen
  • 3,648
  • 4
  • 27
  • 54
  • Why do you want such an alias? Note that if the above case does not hold (one remote-tracking matching name), `git checkout xyzzy` *fails*. So for such a case, you would want your alias to ... fail? :-) – torek Jul 15 '16 at 13:44
  • @torek Edited my question to be more self-describing if you have any further questions don't hesitate to ask them right away I am here to answer. Thanks for your help, in advance. – kuskmen Jul 15 '16 at 13:49
  • Aha, it's a case-folding issue. I'm used to Unix/Linux behavior, where Git is already case-sensitive. I don't think you can fix this with an alias per se, but you could work around it with a script. (It probably deserves a more general fix within Git itself but that's a much bigger project.) – torek Jul 15 '16 at 16:59
  • Ah.. pitty , thanks for the information tho. – kuskmen Jul 18 '16 at 07:21
  • I had something for your title but not for your description. – Knu Jul 19 '16 at 04:30
  • Sorry? I think they are both the same thing or at least one leads to another. – kuskmen Jul 19 '16 at 12:19

0 Answers0