Skip to content

Instantly share code, notes, and snippets.

@undergroundwires
undergroundwires / rename-all-tags.sh
Created May 23, 2020 20:35
Rename all tags in GIT repository from "v.." (e.g. "v1.0.0" to without "v" e.g. "1.0.0")
#!/usr/bin/env bash
push_tag() {
local tag="$1"
echo "Pushing $tag"
git push origin "$tag"
}
delete_tag() {
local tag="$1"
@undergroundwires
undergroundwires / update-all-npm-dependencies.sh
Created October 22, 2020 16:03
update all npm depedendencies
npm i -g npm-check-updates
ncu -u
npm install
@undergroundwires
undergroundwires / set-github-user.sh
Last active May 11, 2021 12:41
set-github-user
git config --local user.name "undergroundwires"
git config --local user.email "git@undergroundwires.dev"
# git config --local user.email "undergroundwires@users.noreply.github.com"
@undergroundwires
undergroundwires / fix-author-email-in-history.sh
Last active August 1, 2021 16:39
fix-author-email-in-history
git filter-branch --env-filter '
OLD_EMAIL="bad@email.com"
CORRECT_NAME="undergroundwires"
CORRECT_EMAIL="git@undergroundwires.dev"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
#!/usr/bin/env bash
# We parse parameter to ensure middleman.sh can be called using:
# 1. Double quoted parameter value chains
# E.g. "--parameter value" "--parameter2 value"
# Designed for GitHub actions as action.yml args is sent this way.
# Parameter value chains are parsed to send in unquoted format
# 2. Parameter value chain
# This is the normal usage, parameters are sent through as they are
# E.g. --parameter value --parameter2 value
git remote set-url origin "ssh://git@github.com/USERNAME/REPOSITORY.git"
# Verify new remote URL
git remote -v
@undergroundwires
undergroundwires / git-aliases.sh
Last active February 12, 2024 08:59
Helpful git aliases
#!/usr/bin/env bash
# bash: `bash ./alias.sh` (requires sudo in macOS)
# zsh: `zsh ./alias.sh`
main() {
local -ra aliases=(
# gitgo : Alias for git add, commit with amend, update commit date and force push
"alias gitgo='git add . && git commit --amend --no-edit --reset-author && git push -f'"
# gitc : Alias for counting total characters in last commi heading
"alias gitc='git log --pretty=format:%Creset%s --no-merges -1 | wc -c'"
@undergroundwires
undergroundwires / gpg-cheatsheet.sh
Last active September 9, 2021 12:19
gpg cheatsheet
# -------------
# -- Create ---
# -------------
# Generate a key
gpg --gen-key
# Generate a key with full wizard
gpg --full-generate-key
@undergroundwires
undergroundwires / remove-path-length-limitation.bat
Created August 31, 2021 15:21
Remove path length limitation in Windows
reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v "LongPathsEnabled" /t REG_DWORD /d 1 /f
@undergroundwires
undergroundwires / set-vim-line-wrapping.sh
Created September 2, 2021 11:20
Seet line wrapping for git commits in vim
echo 'setlocal textwidth=72' > ~/.vimrc
# For troubleshooting, open up git commit message edior and run: ":verbose set tw?"