Skip to content

Instantly share code, notes, and snippets.

@lf94
Created August 13, 2022 22:37
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lf94/d8e7d11a24ddad8315d28741e6d6bf2e to your computer and use it in GitHub Desktop.
Save lf94/d8e7d11a24ddad8315d28741e6d6bf2e to your computer and use it in GitHub Desktop.
GitHub changed the world of open-source.
In the beginning it brought together the disconnected programmers who always wanted to work on something with other like-minded people.
In the present it's no longer the foreground. Businesses and professionals connect and the profiles become a bragging ground.
The GH PR system is stretched to its limits. During the early days this was ok: PRs were few and far between. It worked.
I've changed, and so has GitHub. As I grow older I care more about my impact and personal data responsibility. I care about FOSS work being used for profit.
This is one step in a series towards real code and data ownership (again).
I don't believe GitHub is inherently evil, or bad, but it is having interesting consquences for existing! What I've done is simply a response to its evolution.
I will continue to use GitHub, and even promote GitHub, for certain cases.
Read you later!
-- lf94
@lf94
Copy link
Author

lf94 commented Aug 13, 2022

The script I made to do this is very rudimentary, use at your own risk.

Clone all your repositories into a directory:

mkdir GitHubProjects;
cd GitHubProjects;
CNTX={users|orgs}; NAME={username|orgname}; PAGE=1
curl "https://api.github.com/$CNTX/$NAME/repos?page=$PAGE&per_page=100" |
  grep -e 'clone_url*' |
  cut -d \" -f 4 |
  xargs -L1 git clone

Make a duplicate of all the repositories using cp -r to scrub them.

cd .. && cp -r GitHubProjects GitHubProjects_Scrub

Create a message you'll leave in a file and run the following on the copy of repositories (./shutdown-protocol.sh GitHubProjects_Scrub NewREADME.md).

#!/bin/sh                                                                        
#                                                                                
# Usage: ./shutdown-protocol.sh <directory-of-projects> <message-to-leave>       
#                                                                                
# <directory-of-projects> is a copy of a directory with all your GitHub          
# projects.                                                                      
# <message-to-leave> is a file that will be left in a README.md                  
#                                                                                
# This script deletes all sources except the .git file, git rebases to the       
# beginning and force pushes the new content. It will delete all remote          
# branches.                                                                      
#                                                                                
#                                                                                
                                                                                 
cwd="$PWD"                                                                       
                                                                                 
cleanup() {                                                                      
  echo "$1"                                                                      
  cd "$1"                                                                        
  git fetch --all                                                                
  remotes=$(git branch --remotes)                                                
  echo "$remotes" | sed 's/origin\///' | xargs git push -f -d origin             
  echo "$remotes" | xargs git branch -r -D                                       
  cp .git/config gitconfig                                                       
  sed -i -e 's/https:\/\/github.com\//git@github.com:/' gitconfig                
  find . ! -name 'gitconfig' -exec rm -rf {} +                                   
  git init                                                                       
  mv gitconfig .git/config                                                       
  cp "$cwd"/README.md README.md                                                  
  git add README.md                                                              
  git commit -m "Cleared previous history"                                       
  git push -f origin main                                                        
  git push -f origin master                                                      
  git push -f origin main:master                                                 
  git push -f origin master:main                                                 
}                                                                                
                                                                                 
for d in "$1"/*;                                                                 
do                                                                               
  cleanup "$d" "$2"                                                              
done     

@nothub
Copy link

nothub commented Aug 13, 2022

What are you trying to achieve with this script? The commit data will not be wiped away but still be available on the servers at the companies disposal.

@marlalain
Copy link

You can even delete the repos through the API. Create new ones. And push your message

@nero
Copy link

nero commented Aug 14, 2022

I did a clean sweep in the past by creating a new account and then swapping the handles, deleting the old account. This has the advantage that it disconnects all your activity in issues/pull requests in other projects from you.

@just-Bri
Copy link

"I care about FOSS work being used for profit."
Then educate people about licenses.

The FOSS code on GH does help people make a difference and is not just used for profit by others.

@lf94
Copy link
Author

lf94 commented Aug 14, 2022

@nothub the commit data is not accessible in a public manner at least, which is all I cared about. You're right that once data is submitted to GitHub there is no guarantee it is ever gone. My goal is absolutely more social than technical!

@89z @minsk-dev I don't want to delete repositories because I want to be able to redirect users still (instead of being presented the 404 page)... I could have used the API but functionally what's the difference? I found it quite easy to not use the API for this.

@nero I still want to keep a presence / identity but that's a great idea too 🙂

@just-Bri I'm a little confused because I explicitly say I'm not advocating for people to stop using GitHub... I completely agree it makes a difference. No, I'm not taking responsibility for others to educate themselves. A large issue is the lack of non-commercial FOSS licenses because all NC licenses are not considered free by the FSF. I know of a few but as far as I know none have been battle tested.

Thanks for the comments everyone!

@Amit0617
Copy link

So now you wanna know everytime someone wants access to your code. That's it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment