A bookmarklet for rapid repo cloning. Just click and clone!
v2 - now supports Hugging Face Spaces
![](https://private-user-images.githubusercontent.com/11970940/374079540-da26d168-89b0-4779-af73-3a67e02c41ad.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NTg2MDYsIm5iZiI6MTczODk1ODMwNiwicGF0aCI6Ii8xMTk3MDk0MC8zNzQwNzk1NDAtZGEyNmQxNjgtODliMC00Nzc5LWFmNzMtM2E2N2UwMmM0MWFkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDE5NTgyNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU4ZWIwOTcyOGMwNjI4OTI0OTE4OTQ1MTMyYWIyZTI2ZGFlNDU2MzRmMzgxMTUzMjFjZDZlOTEyNTMwMTc1MmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.INk8QfRIJrpN6-d5J_i1q3ZC8tI1FA0pctdPmy6zyzo)
To quickly clone a repository on Github or Hugging Face Spaces, follow these steps:
-
First, run the server:
- Run the following command to start the server:
python server.py
This starts a local server on port 5000 that will handle the repository cloning.
- Note: The cloned repository will be placed in directory 'github_clones' in the same directory where the server script is run.
- If this work has been helpful to you, you can support it for free by clicking ⭐ to star this repository!
- Run the following command to start the server:
-
Set up the bookmarklet:
- Copy the code below.
- Create a new bookmark in your browser.
- Paste the copied code into the bookmark's URL field.
javascript:(function(){
var serverUrl = 'http://127.0.0.1:5000/clone';
var currentUrl = window.location.href;
var repoUrl;
// Check for GitHub repository
var githubMatch = currentUrl.match(/^https?:\/\/github\.com\/([^\/]+\/[^\/]+)/);
if (githubMatch) {
repoUrl = 'https://github.com/' + githubMatch[1] + '.git';
}
// Check for Hugging Face space
else if (currentUrl.startsWith('https://huggingface.co/spaces/')) {
repoUrl = currentUrl;
}
if (repoUrl) {
window.location.href = serverUrl + '?url=' + encodeURIComponent(repoUrl);
} else {
alert('This doesn\'t appear to be a GitHub repository or Hugging Face space page.');
}
})();
// use with bookmarklet maker https://caiorss.github.io/bookmarklet-maker/
- Using the bookmarklet:
- Once the server is running and you've added the bookmarklet, go to any GitHub repository page or Hugging Face Spaces page.
- Click the bookmark to clone the repo.
- The repo will be cloned in directory 'github_clones' relative to the server.py script
- Once complete, the browser will show a tree output of the files.
-
Note: Developed and tested only on MacOSX.