• 0 Posts
  • 7 Comments
Joined 5 months ago
cake
Cake day: February 8th, 2025

help-circle


  • git() {
      if [ "$1" = "cd" ]; then
        shift
        cd "./$(command git rev-parse --show-cdup)$*"
      else
        command git "$@"
      fi
    }
    

    This lets you run git cd to go to the root of your repo, or git cd foo/bar to go to a path relative to that root. You can’t do it as an alias because it’s conditional, and you can’t do it as a git-cd command because that wouldn’t affect the current shell.