Git and SSH tips

For one of my project I need to manage a different ssh key to deliver the code in an other git repo account. It can be done in .ssh/config using the host configuration but in my case it was the same host.

So I need to set it locally to the repository, here is the command:

git config --add --local core.sshCommand 'ssh -i ~/.ssh/id_rsa_specific_key'

Pull with rebase option

to keep clean history, I prefer to use the rebase option when I pull a branch

git pull --rebase

You also can configure it as you default way to rebase

git config --global pull.rebase true

Pull all branches

To pull all branch, I added the following alias in ~/.gitconfig file :

pull-all = !git branch --format '%(refname:short) %(upstream:track)' | awk '$2 ~  \"behind\" { print $1 }' | "if [ ! -z $i ]; then git pull --rebase origin $i:$i; fi;"

Leave a Reply

Your email address will not be published. Required fields are marked *