Skip to content

Instantly share code, notes, and snippets.

Created March 21, 2020 16:10
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?

git clone and cd function

A simple little alias function that lets you clone and cd into a GitHub repo in one command.


Add to your zsh or bash config (usually ~/.bash_profile or ~/.zshrc) and open a new terminal to be able to use the function.


gcd [github_repo_owner/repo_name]

# For example, the following with clone daneden/zeitgeist and `cd` into it:
gcd daneden/zeitgeist
function __gcd {
if [ "$1x" != "x" ]; then
git clone "$1"
DIRNAME="$(cut -d'/' -f2 <<<$1)"
alias gcd='__gcd'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment