Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Clone in Windows" button - how it works?

Tags:

github

I am curious to how the button works. Can you explain how when I click the "Clone in Windows" button it knows to open a local application(GitHub) on my machine.

like image 242
Noel Avatar asked Nov 20 '12 08:11

Noel


People also ask

What is window clone?

Cloning allows you to create a 1-to-1 copy of your hard drive, which is useful when you need to backup or transfer data. Even better, it also allows you to copy over your Windows 10 installation with your preferences and settings completely intact.

Is it okay to clone Windows?

Cloning a hard drive can avoid the process of time-consuming reinstall the system and reconfigure settings. And cloning is very safe, it plays a significant role in managing and protecting data. The best way to clone a hard drive to SSD is to seek the help of third-party software.


1 Answers

Look at this patch of GitExtension: it register that action in HKCR

  <Component Id="Protocol.github_windows" Guid="*">
    <RegistryKey Key="github-windows" Root="HKCR">
      <RegistryValue Value="URL: Github for Windows Protocol" Type="string" />
      <RegistryValue Name="URL Protocol" Value="" Type="string" />
    </RegistryKey>
    <RegistryKey Key="github-windows\DefaultIcon" Root="HKCR">
      <RegistryValue Value="[INSTALLDIR]GitExtensions.exe" Type="string" />
    </RegistryKey>
    <RegistryKey Root="HKCR" Key="github-windows\shell"/>
    <RegistryKey Root="HKCR" Key="github-windows\shell\open"/>
    <RegistryKey Root="HKCR" Key="github-windows\shell\open\command">
      <RegistryValue Value="&quot;[INSTALLDIR]GitExtensions.exe&quot; %1" Type="string" />
    </RegistryKey>
  </Component>

And it adds:

if (args[1].StartsWith("git://"))
{
    args = new string[]{args[0], "clone", args[1]};
}
if (args[1].StartsWith("github-windows://openRepo/"))
{
     args = new string[]{args[0], "clone", args[1].Replace("github-windows://openRepo/", "")};
}

GitHub for Windows would go for a similar approach.

like image 97
VonC Avatar answered Dec 29 '22 04:12

VonC