Skip to content

Instantly share code, notes, and snippets.

@subnut
Last active April 23, 2022 15:54
Show Gist options
  • Save subnut/62ac277c8f1fa63c03f3818835b78410 to your computer and use it in GitHub Desktop.
Save subnut/62ac277c8f1fa63c03f3818835b78410 to your computer and use it in GitHub Desktop.
Useful git commands

Add remotes

git remote add codeberg "[email protected]:subnut/$(basename $(git rev-parse --show-toplevel)).git"
git remote add github "[email protected]:subnut/$(basename $(git rev-parse --show-toplevel)).git"

Create sed script to update renamed files

git diff HEAD^ | grep ^rename | cut -d ' ' -f 3- | sed 'N;s_\(.*\)\n\(.*\)_s|\1|\2|g_;s_\._\\._g' > sedscript
sed -i -f sedscript **/*(.)     # needs zsh and GNU sed
rm sedscript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment