Skip to content

Instantly share code, notes, and snippets.

@M507
Last active March 19, 2021 16:34
Show Gist options
  • Save M507/169d10e31f0c7e1e726aa532e58e3c9c to your computer and use it in GitHub Desktop.
Save M507/169d10e31f0c7e1e726aa532e58e3c9c to your computer and use it in GitHub Desktop.
Backup public repositories
#!/bin/bash
your_gitlab_profile=gitlab-example.com:username
github_link=$1
folder_name=$(echo $github_link | awk -F'/' '{print $NF}' | rev | cut -c5- | rev)
git clone $github_link $folder_name
cd $folder_name
rm -rf .git/
git init
git add *
git commit -m "Backup script"
git remote add origin git@$your_gitlab_domain/$folder_name.git
git push -u origin master
cd ..
rm -rf $folder_name
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment