Skip to content

Instantly share code, notes, and snippets.

@andresjesse
Last active April 18, 2023 21:04
Show Gist options
  • Save andresjesse/c4eea9c925520d374100a12a7aaea917 to your computer and use it in GitHub Desktop.
Save andresjesse/c4eea9c925520d374100a12a7aaea917 to your computer and use it in GitHub Desktop.

Clean local branches except master|main|develop:

git branch | grep -v '\*\|master\|main\|develop\|staging\|production' | xargs -n 1 git branch -D

Execute a command using an specific ssh key:

git -c core.sshCommand="ssh -i ~/.ssh/id_ed25519" push origin main

Clone a project using an specific ssh key:

git -c core.sshCommand="ssh -i ~/.ssh/id_ed25519" clone git@...repo.git

Set ssh key per project:

git config core.sshCommand "ssh -i ~/.ssh/id_ed25519"

Changing committer name and email per repository

git config user.name "John Doe" git config user.email "john@doe.org"

Generate ssh PEM key for deploy keys

ssh-keygen -t rsa -m PEM

Reset author for all branch commits

git rebase -r --root --exec "git commit --amend --no-edit --reset-author"

SSHFS

Mount remote folder using an specific ssh key

sshfs -o IdentityFile=/home/andres/.ssh/id_ed25519 USER@SERVER:/home/ubuntu .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment