The following three steps only need to be conducted once per machine or repository you are working with.
We recommend creating a dedicated directory for Github in your home user directory. For Windows, it is usually, for example, C:\Users\naomi\Github
, and for Macs, for example, /Users/naomi/Github
.
SSH is a security protocol that enables computers to talk to each other using public key cryptography. Each user is required to have a private and public key pair to securely access your Github account when working from the command line.
To check if you already have this:
- In your home directory, type:
ls -la
- Look for a directory called
.ssh
a. If you have this directory, you already have a key b. If you do NOT have this directory, you will need to make one.
To make a new key, you will need to:
- Create a private/public key pair: https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
- Add it to your Github account: https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/
Once your key has been set up and linked, all you need to do is clone (which is like downloading) a copy of the repository to your local Githun directory you created in step 1 above.
You will need to copy the SSH address your repository - see Cloning a Repository for a visual guide of where this is on the repo homepage. Make sure to grab the SSH one and not the HTTPS or GitHub CLI addresses. It should look something like git@github.com:cu-mkp/editioncrafter-data.git
.
In the command line, navigate to your Github directory, then do: git clone [paste the SSH address here]
.
For example, git clone git@github.com:cu-mkp/editioncrafter-data.git
- Create issue (or find one already created)
- Assign to someone (or yourself)
- Open the command line
- If you are using the Linux Subsystem for Windows, run the command:
winhome
- Navigate to the repository you want to work in, e.g.,
m-k-manuscript-data
- For example, if this is where you start:
/mnt/c/Users/naomi/
, run the commands: - /mnt/c/Users/naomi/
cd Github
- /mnt/c/Users/naomi/Github/
cd m-k-manuscript-data
- For example, if this is where you start:
- Pull the most updated version of the repository
git fetch
git pull
- Create new branch titled "issue[##]" (no spaces or special characters)
git checkout -b [name of branch e.g. issue73]
- Make edits to repository files (in text editors such as Sublime, oXygen, or in whatever program suits the files you are working with)
- Add file in local repository for tracking in github repository
git add .
git commit -m '#[issue##]: [commit message]'
(this will ensure that this commit us linked to the issue you are working on)
- Push to the remote server (for the first time, MUST BE TRACKED)
git push -u origin [branchname]
- Submit a pull request in github interface (browser) to merge your issue branch with master
- Go to the "pull request" tab where a message should appear asking if you would like to open a pull request
- Another option: In branch dropdown menu, select the branch you want to merge, then hit the "new pull request"
- THC or NJR will merge the pull request unless there are conflicts to be resolved
- Close the issue
git checkout master
(= switch back to master branch)git checkout main
(master/main depending on the repository)
pwd
"print working directory" -- tells you where you are in the command linels
"list" -- tells you what files and folders are in the directory you are incd
"change directory" -- this followed by the name of the directory or a path will move you to that directorycd ..
-- moves you up one directoryless
[name of file] script readerq
"quit" -- exit out of a programming that is running
- See also https://www.git-tower.com/learn/git/faq/checkout-remote-branch
- Navigate into the desired directory (i.e. m-k-manuscript-data)
git branch
(tells you which branch you are in)git fetch
(tells you what is happening in remote repo)git status
(tells you which branch you're on and how far ahead or behind you are from Origin)- If status is behind, pull the most current version
git fetch
git pull