diff options
author | Christian Cleberg <hello@cleberg.net> | 2024-04-29 14:18:55 -0500 |
---|---|---|
committer | Christian Cleberg <hello@cleberg.net> | 2024-04-29 14:18:55 -0500 |
commit | fdd80eadcc2f147d0198d94b7b908764778184a2 (patch) | |
tree | fbec9522ea9aa13e8105efc413d2498c3c5b4cd6 /content/blog/2021-03-19-clone-github-repos.md | |
parent | d6c80fdc1dea9ff242a4d3c7d3939d2727a8da56 (diff) | |
download | cleberg.net-fdd80eadcc2f147d0198d94b7b908764778184a2.tar.gz cleberg.net-fdd80eadcc2f147d0198d94b7b908764778184a2.tar.bz2 cleberg.net-fdd80eadcc2f147d0198d94b7b908764778184a2.zip |
format line wrapping and fix escaped characters
Diffstat (limited to 'content/blog/2021-03-19-clone-github-repos.md')
-rw-r--r-- | content/blog/2021-03-19-clone-github-repos.md | 65 |
1 files changed, 30 insertions, 35 deletions
diff --git a/content/blog/2021-03-19-clone-github-repos.md b/content/blog/2021-03-19-clone-github-repos.md index f5db436..e2b1ce0 100644 --- a/content/blog/2021-03-19-clone-github-repos.md +++ b/content/blog/2021-03-19-clone-github-repos.md @@ -7,29 +7,27 @@ draft = false # Cloning from GitHub -If you\'re like me and use a lot of different devices (and sometimes -decide to just wipe your device and start with a new OS), you probably -know the pain of cloning all your old code repositories down to your -local file system. +If you're like me and use a lot of different devices (and sometimes decide to +just wipe your device and start with a new OS), you probably know the pain of +cloning all your old code repositories down to your local file system. -If you\'re using GitHub, you can easily clone all of your code back down -in just seconds. First, create a bash script. I do so by opening a new -file in `nano`, but you can use `gedit`, -`vim`, or something else: +If you're using GitHub, you can easily clone all of your code back down in just +seconds. First, create a bash script. I do so by opening a new file in `nano`, +but you can use `gedit`, `vim`, or something else: ```sh nano clone_github_repos.sh ``` -Next, paste in the following information. Note that you can replace the -word `users` in the first line with `orgs` and -type an organization\'s name instead of a user\'s name. +Next, paste in the following information. Note that you can replace the word +`users` in the first line with `orgs` and type an organization's name instead +of a user's name. ```sh CNTX=users; NAME=YOUR-USERNAME; PAGE=1 curl "https://api.github.com/$CNTX/$NAME/repos?page=$PAGE&per_page=100" | grep -e 'git_url*' | - cut -d \" -f 4 | + cut -d " -f 4 | xargs -L1 git clone ``` @@ -47,12 +45,12 @@ Now you can run the script and should see the cloning process begin. # Cloning from Sourcehut -I haven\'t fully figured out how to directly incorporate Sourcehut\'s -GraphQL API into a bash script yet, so this one will take two steps. +I haven't fully figured out how to directly incorporate Sourcehut's GraphQL +API into a bash script yet, so this one will take two steps. First, log-in to Sourcehut and go to their [GraphQL playground for -Git](https://git.sr.ht/graphql). Next, paste the following query into -the left box: +Git](https://git.sr.ht/graphql). Next, paste the following query into the left +box: ```sh query { @@ -68,24 +66,22 @@ query { } ``` -The output on the right side will give you an object of all your -repositories. Just grab that text and remove all the characters such as -quotation marks and curly brackets. You will need a single-line list of -space-separated values for the next step. +The output on the right side will give you an object of all your repositories. +Just grab that text and remove all the characters such as quotation marks and +curly brackets. You will need a single-line list of space-separated values for +the next step. -Now let\'s create the bash script: +Now let's create the bash script: ```sh nano clone_sourcehut_repos.sh ``` -Next, paste the following bash script in with the list of repositories -you obtained above and replace `your-username` with your -username. +Next, paste the following bash script in with the list of repositories you +obtained above and replace `your-username` with your username. -Note that this uses the SSH-based Git cloning method (e.g. -`git@git...`), so you\'ll need to ensure you have set up -Sourcehut with your SSH key. +Note that this uses the SSH-based Git cloning method (e.g. `git@git...`), so +you'll need to ensure you have set up Sourcehut with your SSH key. ```sh repos=(repo1 repo2 repo3) @@ -112,19 +108,18 @@ Now you can run the script and should see the cloning process begin. # Moving Repositories to a New Host -Now that you have all of your code repositories cloned to your local -computer, you may want to change the remote host (e.g., moving from -GitHub to GitLab). To do this, let\'s create another bash script: +Now that you have all of your code repositories cloned to your local computer, +you may want to change the remote host (e.g., moving from GitHub to GitLab). To +do this, let's create another bash script: ```sh nano change_remote_urls.sh ``` -Past the following information and be sure to change the URL information -to whichever host you are moving to. For this example, I am looping -through all of my cloned GitHub directories and changing them to -Sourcehut (e.g. `<YOUR_NEW_REMOTE_URL>` -\> -`git@git.sr.ht:~myusername`). +Past the following information and be sure to change the URL information to +whichever host you are moving to. For this example, I am looping through all of +my cloned GitHub directories and changing them to Sourcehut (e.g. +`<YOUR_NEW_REMOTE_URL>` -> `git@git.sr.ht:~myusername`). ```sh # List all sub-directories in the current directory |