Git Clone: The Quickening!
I’ve been using Visual Studio Online for a bit, so the example in this post will specifically show that, but the concept applies anywhere.
If you have a project up there named foo, the git clone
URI is something like
https://you.visualstudio.com/DefaultCollection/_git/foo
It’s a real pain to type all that. So I did this in my .gitconfig
[alias]
qc-ds = "!f() { p=${1}; d=${2-$1}; git clone https://me.visualstudio.com/DefaultCollection/_git/$p $d; }; f"
Usage⌗
To clone myproject
into myproject
,
git qc-ds myproject
To clone myproject
into somedirectory
,
git qc-ds myproject somedirectory
Breakdown⌗
qc stands for quick clone.
ds is an abbreviation of the me
part of my VSO account. It’s meaningful to me. Make yours whatever you want.
The rest creates a function and executes it. The first argument is assigned to p
(“project”). The second is optional and is assigned to d
(“directory”). It defaults to p
if not supplied. Then it’s just filling in the blanks.
Caveat⌗
This gets a little weirder if you have multiple repositories in a project, e.g. a second repo named bar inside of the foo project
https://you.visualstudio.com/DefaultCollection/foo/_git/bar
I know how I’m going to tackle this, but I will leave it as an exercise for the reader.
And of course, if you’re on GitHub, BitBucket, or whatever…the repo URIs are usually pretty standard. Just :s it!