Skip to content

Instantly share code, notes, and snippets.

View npasserini's full-sized avatar

Nico Passerini npasserini

View GitHub Profile
@npasserini
npasserini / list-dangling-commits.sh
Created September 22, 2018 12:28
List dangling commits
#!/bin/bash
PAGER= \
&& git fsck --full --no-reflogs --unreachable --lost-found \
| grep commit \
| awk '{print $3}' \
| xargs -n 1 git log -n 1 --pretty=oneline
@npasserini
npasserini / rebaseBranchSequence
Last active May 11, 2018 03:15
Rebase a sequence of connected branches, each one depending on the previous one.
# This is useful for repositories holding several stages of a same example, as some teachers do for their class examples.
# This strategy is useful for showing different steps of the construction of a piece of software.
# The problem is that if you have to change something in one of the initial branches, you have to rebase all following ones.
# This script can help automate that process.
# In my case the initial branch is named `inicioClaseHerencia`
# And all dependent branches are named `punto1-...` to `punto#-...`, so they can be find with a pattern.
old=inicioClaseHerencia
for b in `gb --list "punto*"`; do
@npasserini
npasserini / git-interactive-checkout.sh
Created October 24, 2017 15:20
A menu for selecting branches to checkout
#!/bin/bash
TITLE="Branch Selector"
MENU="Select a branch to checkout:"
DEFAULT_BRANCH=$(git symbolic-ref -q HEAD)
DEFAULT_BRANCH=${DEFAULT_BRANCH##refs/heads/}
DEFAULT=0
OPTIONS=()
tempBranches=()
Array.prototype.slice
.apply(document.querySelectorAll('.js-subscription-row'))
.filter(el => el.querySelector('a[href^="/dds-utn"]'))
.map(el => el.querySelector('button'))
.forEach(btn => btn.click())
@npasserini
npasserini / git-purge-branches
Created March 23, 2017 11:38
Removes already pushed branches from your local repository.
currentBranch=$(git rev-parse --abbrev-ref HEAD)
ignore=(dev master)
function red {
echo -e "\e[1;31m$1\e[0m"
}
function green {
echo -e "\e[1;32m$1\e[0m"
}
"See if the monticello registry has misplaced objects (i.e. not MCPackages)"
MCWorkingCopy registry keys collect: #class as: Set.
"Clean the registry"
MCWorkingCopy registry removeKey:
(MCWorkingCopy registry keys detect: [ :key | key class ~= MCPackage ]).