0

On my course, very often we git clone and then cd into the folder we just made. We've got hundreds of repositories and so it would have saved/ continue to save a lot of time. Especially when the things we are cloning have similar names.

I have tried googling the problem and tried appending some things onto the git clone 'repo here' line.

For example i'm in a folder called week 4, what I currently do is copy a repo lets say 'advanced-JS', then gcl advanced-JS, then cd advanced-JS. But what id like to do it type gcl advanced-JS (x), for it to clone it onto my computer and cd into the folder it just made. x being the unknown here.

Thank you.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120

1 Answers1

2

As has been described here (and similar places):

you can create a shell function:

gclonecd() {
   git clone "$1" && cd "$(basename "$1" .git)"
}
tkruse
  • 10,222
  • 7
  • 53
  • 80