Git configuration and environment - NOAA-GFDL/MOM6-examples GitHub Wiki
git configuration and environment
git is the SCM (source code management) system of choice and the code is hosted on GitHub. To contribute, you need to have an account on GitHub and have uploaded some ssh keys so that git can "talk" to GitHub. See GitHub's tutorial on generating ssh keys. You do not need a GitHub account to use git to clone (download) from GitHub.
git version
It is helpful to have a recent version of git. Some features such as sub-modules are relatively new. GitHub recommend to use at least version 1.7.10. Use
git --version
to find out what version you have. These instructions on this wiki have been tested with `git --version`` 1.7.10.4.
Your environment
First be sure you have access to git. On the gaea machine you might need to do:
module load git
Your git configuration
Be sure that you have configured git correctly. You only have to do this once ever per platform. You must let git know your full name and email as they should appear in commits and requests:
git config --global user.name "Robert Griffies"
git config --global user.email "[email protected]"
Caching your password
If you are using the HTTPS protocol instead of SSH you will find it useful for git to remember you credentials for a period. You can configure this with:
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=3600'
Tip
Turn on "colors" in git for with:
git config --global color.ui true
Choose tkdiff for difftool and avoid prompts:
git config --global diff.tool tkdiff
git config --global difftool.prompt false
Now return to Getting Started.
Use the gh command line to cache credentials
Install gh (the GitHub command line tool), e.g.:
sudo apt install gh
(or brew install gh on a Mac).
Use gh to authenticate via a PAT (personal access token):
gh auth login
Select "GitHub.com", "HTTPS", "Paste an authentication token". For the last step you will now need to create a PAT.
To create a PAT:
- Goto https://github.com/ (make sure you are logged in)
- Pull down the menu for your account and select "Settings"
- Click "<> Developer Settings" at the bottom of the left column.
- Click "Personal Access Tokens" in the left column.
- Click "Generate New Token"
- Give the token a meaningful note, such as the name of the machine you are accessing from.
- Check "repro" and "read:org"
- Click "Generate Token" (bottom of form)
- Copy the token from the web page, and paste it to the terminal where you have the
ghprompt for the authentication token.
Configure git to use credential caching:
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=3600'