I have a repo (origin) on a USB key that I cloned on my hard drive (local). I moved \"origin\" to a NAS and successfully tested cloning it from here.
I would like to
Change remote git URI to
git@github.com
rather thanhttps://github.com
git remote set-url origin git@github.com:/.git
Example:
git remote set-url origin git@github.com:Chetabahana/my_repo_name.git
The benefit is that you may do git push automatically when you use ssh-agent :
#!/bin/bash
# Check ssh connection
ssh-add -l &>/dev/null
[[ "$?" == 2 ]] && eval `ssh-agent`
ssh-add -l &>/dev/null
[[ "$?" == 1 ]] && expect $HOME/.ssh/agent
# Send git commands to push
git add . && git commit -m "your commit" && git push -u origin master
Put a script file $HOME/.ssh/agent
to let it runs ssh-add
using expect as below:
#!/usr/bin/expect -f
set HOME $env(HOME)
spawn ssh-add $HOME/.ssh/id_rsa
expect "Enter passphrase for $HOME/.ssh/id_rsa:"
send "\n";
expect "Identity added: $HOME/.ssh/id_rsa ($HOME/.ssh/id_rsa)"
interact