GitHub Project Graveyard
Introduction
So I decided to look at my presense online and I realised that I have been neglecting my GitHub a lot. I don’t have a profile and I have lots and lots of old projects that I have no intention of maintaining.
I could just delete a heap of my old modules but I thought some people might still get some use out of them. So instead of just archiving them and leaving them lying around I decieded to create a github project graveyard.
What is a GitHub Project Graveyard?
A GitHub Project Graveyard is simply a repository that I called .graveyard
and started putting all the projects I deemed dead into sub folders.
The nice thing about doing this is I can set a github action to reject all pull requests on it and setup dependabot to ignore it.
How to setup a GitHub Project Graveyard
This is pretty easy to do. Simply create a new repository called .graveyard
and stick a readme file in there telling
people what it is and not to contact you for support.
I then like to go into settings and disable as much as possible like no issues and no wiki etc.
Pull requests are one thing that github is a pain about. They don’t give you the option to turn them off so I just add the following github action that will auto reject them.
Create this file at .github/workflows/reject.yml
name: Reject Pull Requests
on:
pull_request_target:
types: [opened, reopened]
jobs:
reject:
runs-on: ubuntu-latest
steps:
- name: Reject PR
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = context.payload.pull_request;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body: '❌ This repository does not accept pull requests.'
});
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
state: 'closed'
});
On top of turning dependabot off I also like to set its settings file to nothing in case it does run.
version: 2
updates: [] # Empty updates section effectively disables Dependabot
Next up I turn all dependabot checks off and then I go into settings and disable the repository.
Moving projects into the graveyard
There are a few ways to do this. The easiest way is to just copy the latest version of the project into a sub folder in the repo and push it.
The other more archival way of doing it is to make use of some github foo to merge the old repository history into the .graveyard repository and move the contents into a sub folder.
How to move a project into the graveyard
This assumes you have already cloned your graveyard repository.
To start with you need to clone the repository you want to archive to disk:
git clone https://github.com/username/project.git
Next you need to use a tool called git-filter-repo
which you can install with:
pip install git-filter-repo
Now we need to move all of the files into a sub directory that is unique in the graveyard repositrory.
git filter-repo --to-subdirectory-filter projectname
If the repository has a master branch you can rename it to main with:
git branch -M main
Now change directory to your graveyard repository and we will add the project repository as a remote.
# Change this to where ever you store your graveyard repository
cd ~/repos/.graveyard
# This is the path to the project repository you cloned above.
git remote add temp ../projectname
git fetch temp
git merge --allow-unrelated-histories temp/main
If you have other branches you want to grab you can create them and merge them like the above. I usually don’t and just grab the main branch but it depends on the project and what you want to store.
Finally clean up by removing the temp remote and pushing your changes.
git remote rm temp
git push