Basic Git/GitHub Skills in JupyterLab git GUI
Create a GitHub account
For access to the NMFS Openscapes JupyterHub, you will need at GitHub account. See the main HackHour page on how to request access (NOAA staff). For NMFS staff, you can look at the NMFS OpenSci GitHub Guide information for how to create your user account and you will find lots of information on the NMFS GitHub Governance Team Training Page (visible only to NOAA staff).
Setting up Git Authentication
Before we can work with Git in the JupyterHub, your need to authenticate. Do the steps here: Git Authentication
Git extension in JupyterLab
When the instructions say to use or open or click the Git GUI, look here:
The Key Skills
Skill 1: Create a blank repo on GitHub
Skill 2: Clone your GitHub repo
Skill 3: Make some changes and commit those local changes
Skill 4: Push the changes to GitHub
Skill 1b: Copy someone else’s GitHub repository
Let’s see it done!
Skill 1: Create a blank repo on GitHub
- Click the + in the upper left from YOUR GitHub account (https://www.github.com/yourusername).
- Give your repo the name
Test
and make sure it is public. - Click new and check checkbox to add the Readme file and
.gitignore
- Copy the URL of your new repo. It’s in the browser where you normally see a URL.
Skill 2: Clone your repo
First make sure you are at the home directory level. Look at the folder icon under the blue launcher button. It should show, folder icon only like in this image. If not, then click on the folder icon.
- Copy the URL of your repo.
https://www.github.com/yourname/Test
- Click on the git icon and then click “Clone a Repository”
- Paste in the URL of your repo from Step 1
- Click Clone. You can stay with the defaults for the checkboxes.
Skill 3: Make some changes and commit your changes
This writes a note about what changes you have made. It also marks a ‘point’ in time that you can go back to if you need to.
- Click on the README.md file in the Test repo.
- Make some changes to the file.
- Click the Git icon (in left navbar), and stage the change(s) by checking the “+” next to the files listed.
- Add a commit message in the box.
- Click the Commit button at bottom.
Skill 4: Push changes to GitHub / Pull changes from GitHub
To push changes you committed in Skill #3
- From Git icon, look for the little cloud at the top. It is rather small. Click that to push changes.
To pull changes on GitHub that are not on your local computer:
- Make some changes directly on GitHub (not in JupyterLab)
- From Git icon, click on the little cloud with a down arrow.
Activity 1
- Make a copy of README.md
- Rename it to
.md - Add some text.
- Stage and commit the added file.
- Push to GitHub.
Activity 2
- In the Test repo, create a file called to
<yourname>.md
. - Stage and then commit that new file.
- Push to GitHub.
- Make some more changes and push to GitHub.
Activity 3
You can copy your own or other people’s repos1.
- In a browser, go to the GitHub repository https://github.com/RWorkflow-Workshops/Week5
- Copy its URL.
- Navigate to your GitHub page: click your icon in the upper right and then ‘your repositories’
- Click the
+
in top right and clickimport repository
. Paste in the URL and give your repo a name. - Use Skill #1 to clone your new repo to JupyterLab
Clean up after you are done
Open a Terminal
Type
cd ~ rm -rf Test rm -rf Week5
Footnotes
This is different from forking. There is no connection to the original repository.↩︎