Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How to cd automatically after git clone?

I want to automatically cd to the directory created by the clone command after I git cloned something.

Important: I don't want to alter the syntax for the command (e.g. use an alias/function) because it would break the zsh-completions I get automatically from the Pretzo project.

EDIT: The reason I didn't pick any answer as correct, is because no answer was given that did comply with the condition above.

I use ZSH, but an answer in any other shell is acceptable as well.
by

1 Answer

Bharatv4tg1
Create a function:
gclonecd() {
git clone "$1" && cd "$(basename "$1" .git)"
}

(Works for links both with and without ".git")

Login / Signup to Answer the Question.