- Vimeo (company) git creds are used only inside (all levels)
~/vimeo-work
folder. - All other locations use personal GitHub credentials.
No special syntax needed.
Special syntax is needed only at 'clone' time for Vimeo work repos(which are kept in ~/vimeo-work
of course)
All files (real examples) can be found in this Gist.
- Create the work folder
- Set up the
~/company-work/.gitconfig
file. - Set up the
~/.gitconfig
file. - Set up the SSH keys
- Generate keys on Github.com from personal and work accounts. Make sure to name the keys properly in terminal during key generation.
- Set up the
~/.ssh/config
file based on keys.
Done!
- Go to ~/vimeo-work
- Edit the SSH URL.
Make it
github.com-vimeo
instead ofgithub.com
. Example:[email protected]:vhx/myRepo.git
-->[email protected]:vhx/myRepo.git
- That's all.
The config for a vimeo repo has the needed credentials. No special syntax is needed.
The idea:
git config --add --local core.sshCommand 'ssh -i <<<PATH_TO_SSH_KEY>>>'
# this refers to the key file (has no extension), not the .pub file
# FYI, the .pub contents are pasted on GitHub
Why is this way good:
- This is the easiest since it's easy to add, easy to remove
- Should be the way if the computer being used is temporary, e.g. like a spare laptop, internet cafe etc.
Exact steps:
# 1. clone the repo
git clone my-repo-url
# 2. go to repo path
cd my-repo
# 3. generate the key pair
ssh-keygen -t rsa -b 4096 -C "[email protected]" -f my_new_key
# 4. add the key to the repo config
git config --add --local core.sshCommand 'ssh -i my_new_key'
# 5. Copy the public key (output)
cat my_new_key.pub
- Finally, create a key on GitHub using the copied content. Link: https://github.com/settings/ssh/new
- Done!
Note:
- Make sure to delete the SSH key if computer is not own.
- If SSH is kept inside repo itself - make sure it's
.gitignore
d.
Here from the medium.com article? Shorthands: https://gist.github.com/sanjarcode/92aa6a164d16e51c343eed926047fb1f