Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • The trouble with this approach is that it breaks returning to the previous current working directory using cd - . It will also cd to / if it can't find the .git directory.
    – Flimm
    Commented Nov 23, 2023 at 14:27
  • Good point about ending up in /, easily rectified. Your question doesn't mention anything about preserving cd - so that wasn't in consideration.
    – bxm
    Commented Nov 23, 2023 at 21:21