Skip to content

Instantly share code, notes, and snippets.

@mpalpha
Created August 18, 2021 22:31
Show Gist options
  • Save mpalpha/bece429d8e14ccf56de6137555a48b36 to your computer and use it in GitHub Desktop.
Save mpalpha/bece429d8e14ccf56de6137555a48b36 to your computer and use it in GitHub Desktop.
git clone and cd into

Installation

You can add the gcd script to your local bin path or you can add the followin snippet to your bash .profile or zsh .zshrc file.

function gcd {
  REPO=$1
  CLONEPATH=$2

  if [ -z $CLONEPATH ]; then
      CLONEPATH=${$(basename $1)/.git/}
  fi

  git clone $REPO $CLONEPATH
  cd $CLONEPATH
}

Usage

gcd https://github.com/laravel/laravel.git
(git clone https://github.com/laravel/laravel.git && cd laravel)

gcd https://github.com/laravel/laravel.git phpthebestway
(git clone https://github.com/laravel/laravel.git phpthebestway && cd phpthebestway)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment