-
Notifications
You must be signed in to change notification settings - Fork 0
GitHub
Neal W Morton edited this page Jul 24, 2018
·
6 revisions
- Get an account on GitHub
- Send Neal your username so you can be added to the prestonlab group
- To install using the GitHub app (does not work on TACC or on older
Macs):
- Install the app from the GitHub website
- Sign into your account
- Click on the + icon in the upper left; go to the clone tab
- You should see the repository if you have access to it
- Select the one you want and click the Clone button, then select where you want to place the repository
- To install using ssh (does not require entering a password when
installing code or making changes):
- Set up an SSH key with GitHub (you only need to do this once for each computer, and then it will work for other code repositories). See the section "Adding an SSH key" below.
- On GitHub, go to the page of the project you want. In the lower right, click on SSH so that the SSH clone URL is displayed. This is the URL you need to clone the repository.
- On the computer where you want the code, type
git clone [SSH clone URL]
, for examplegit clone [email protected]:prestonlab/fat.git
to download the repository.
- To install using HTTPS (requires entering a password when making any
changes; doesn't seem to work on TACC):
- On GitHub, go to the page of the project you want. In the lower right, click on HTTPS so that the HTTPS clone URL is displayed. This is the URL you need to clone the repository.
- On the computer where you want the code, type
git clone [HTTPS clone URL]
, for examplegit clone https://github.com/prestonlab/fat.git
. - Enter your GitHub username and password to download the repository.
Follow these steps to add an SSH key to GitHub so you can push and pull from git projects without having to enter your password.
- On the computer where you want the code, check if there is a file in
~/.ssh/id_rsa.pub
. If not, in the terminal runssh-keygen
. Hit enter through all the options to create a passwordless key. - Type
cat ~/.ssh/id_rsa.pub
; this will display the public key that you just created. Go to your account page on GitHub and click the settings icon in the upper right. Click on the "SSH keys" tab, then "Add SSH Key". - Copy the public key into the box; give the key a title so you will know what computer it corresponds to. You will need to generate and add a different key for each computer you use.
If you want to manage your own code for a project (e.g. study-specific code) through the lab's GitHub account, in a directory called "analysis" in the home directory:
- Go on GitHub and create a new project under the prestonlab organization
- Clone the project:
cd ~/analysis; git clone [email protected]:prestonlab/[projectname].git
- Add scripts to the directory
- See the status of the project:
cd ~/analysis/[projectname]; git status
. You should see each of the script you added. - Add those scripts to the list of changes to commit:
git add [script1] [script2] ...
- Make the list of changes to the project:
git commit -m 'add scripts for analyzing behavioral data'
. - The -m flag is very important, since it describes the changes in each commit and can help a lot with keeping track of changes to code over time. It's required, so if you don't specify it, a text editor will open so you can write a message there.
- Push the changes to GitHub:
git push
. This will backup your changes, and will make them accessible to other people with access to your project - To get the latest code from GitHub:
git pull
. This will pull in any changes and attempt to merge them with the versions of the files you have locally.