Set up git on linux or OS X
We will assume the sysadmin has git already installed on the system. Before you can get started using the github.nrel.gov git repos, you'll have to do some basic setup. This includes:
- Basic git configuration
- Setting up ssh keys
Basic git configuration setup
Git needs to know your user name and an email address at a minimum.
$ git config --global user.name "Your name" $ git config --global user.email "email@example.com"
Set up your ssh keys
If you are trying to use git on one of the HPC systems such as Peregrine, you already have SSH keys created on those systems! If this is the case, go to git 101 for more info!
You probably have ssh keys set up on your Linux, HPC, or Apple OS X system (MacBook Pro) already, but if not, follow these steps to setup your ssh keys.
1. Check for existing SSH keys
Have an existing key pair? You can skip to Step 4.
First, we need to check for existing ssh keys on your computer:
$ cd ~/.ssh
...checks to see if there is a directory named `.ssh` in your home directory. If it says "No such file or directory" skip to step 3. Otherwise continue to step 2.
2. Backup existing SSH keys
Since there is already a ~/.ssh directory you'll want to back it up just in case:
$ ls config id_rsa id_rsa.pub known_hosts $ mkdir key_backup $ cp id_r* key_backup
3. Generate a new SSH key for git repos
NOTE: DO NOT do this on the HPC systems, such as Peregrine. Peregrine already has keys generated!
To generate a new SSH key, enter the code below. We want the default settings. So when asked to enter a file in which to save the key, just press enter.
$ ssh-keygen -t rsa
Passphrases... In this case, please just hit return. Yes, it's more secure to enter a passphrase.
Generating public/private rsa key pair. Enter passphrase (empty for no passphrase):<enter a passphrase> Enter same passphrase again:<enter passphrase again>
Which should give you something like this:
Your identification has been saved in id_rsa. Your public key has been saved in id_rsa.pub. The key fingerprint is: 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db USER@HOSTNAME The key's randomart image is: +--[ RSA 2048]----+ | | | | | | | o o | | + = S . o | | o o + . . + o | | . o o ..= | | o E +o..| | . ..oB= | +-----------------+
Next Steps - using a remote git repository
Now you have all the basic configuration for using git with a remote repository ready. Your next steps will be to get access to a git repository, clone the repo, and learn how to add code and commit changes to your repo. Go to git 101 for more info.