Skip to content

Instantly share code, notes, and snippets.

@spikespaz
Created August 29, 2024 06:29
Show Gist options
  • Save spikespaz/0ebf30bdaf69c34cab9e3a210cb35ea1 to your computer and use it in GitHub Desktop.
Save spikespaz/0ebf30bdaf69c34cab9e3a210cb35ea1 to your computer and use it in GitHub Desktop.
Scripts for Git and friends

Git Scripts

Gist with files I have used for managing Git repositories

#! /usr/bin/env nix-shell
#! nix-shell -i bash -p git git-filter-repo
# shellcheck shell=bash
set -euo pipefail
github_org=spikespaz
new_crate=dotwalk-rs
new_branch=rustc_dotgraph
if [ ! -d rust ]; then
git clone [email protected]:rust-lang/rust.git
fi
if [ -d $new_crate ]; then
echo "directory '$new_crate' already exists, please delete it"
exit 1
fi
cp -r rust $new_crate
pushd $new_crate
# faster than using --source and --target
# cp -r rust $new_crate
# git init $new_crate
# --source rust \
# --target $new_crate \
git filter-repo \
--path src/libgraphviz \
--path src/librustc_graphviz \
--path compiler/rustc_graphviz \
--subdirectory-filter src/libgraphviz \
--subdirectory-filter src/librustc_graphviz \
--subdirectory-filter compiler/rustc_graphviz \
--prune-empty always \
--prune-degenerate always \
--no-ff
# pushd $new_crate
git remote add origin [email protected]:$github_org/$new_crate.git
git branch -m $new_branch
git push --force --set-upstream origin $new_branch
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment