sciware

Sciware

Intro to GitHub

https://sciware.flatironinstitute.org/21_IntroGithub

https://github.com/flatironinstitute/learn-sciware-dev/tree/master/21_IntroGithub

Rules of Engagement

Goal:

Activities where participants all actively work to foster an environment which encourages participation across experience levels, coding language fluency, technology choices*, and scientific disciplines.

*though sometimes we try to expand your options

Rules of Engagement

(These will always be a work in progress and will be updated, clarified, or expanded as needed.)

Zoom Specific

Future Sessions

Today’s Agenda

Intro to Git and GitHub

Version control

an open-source, distributed, command-line, version-control tool

GitHub

Setting up GitHub on your Computer

Make sure git is installed

 > git version
git version 2.30.1

If this returns an error, please raise your hand or put a yellow sticky on your laptop.

Setting your name in Git

See what name is currently set

 > git config --global user.name

Set your full name

 > git config --global user.name "Mona Lisa"

Setting your email address

See what email address is currently set

 > git config --global user.email

Set an email address

 > git config --global user.email "youremail@flatironinstitute.org"

(Ideally set to the same email address you used for GitHub account)

Generate an SSH key

 > ssh-keygen -t ed25519
 > cat ~/.ssh/id_ed25519.pub
ssh-ed25519 AAA..... user@host

Copy this whole line to the clipboard

Add the SSH key to GitHub

Settings screenshot SSH Keys screenshot

Add the SSH key to GitHub

Setup Git’s default text editor

So that you don’t get stuck in vi:

 > git config --global core.editor "nano -w"

How to set up your favorite editor with Git:

https://git-scm.com/book/en/v2/Appendix-C%3A-Git-Commands-Setup-and-Config#ch_core_editor

Questions?

Getting code from GitHub onto your computer

Clone graphic

GitHub Jargon

Clone graphic

Download the code to your computer in GitHub-ese is Clone the Repo to your local

Clone the repo

Clone button screenshot

Clone the repo (continued…)

 > git clone git@github.com:flatironinstitute/sciware21-git-intro
> cd sciware21-git-intro

What does git clone do?

 > ls -a
 > git remote -v
origin  git@github.com:flatironinstitute/sciware21-git-intro (fetch)
origin  git@github.com:flatironinstitute/sciware21-git-intro (push)

Questions?

Clone graphic

Activity

Find a repo and clone it to your computer

https://github.com/explore

Survey

http://bit.ly/sciware-github1-2022

Putting code on GitHub

Push to remote graphic

Make a project directory (folder)

 
> cd #out of sciware21-git-intro
> mkdir silly_repo
> cd silly_repo
> touch silly_code.py
> touch silly_file.txt

Local graphic

Create a repo on GitHub

remote graphic

Initialize the directory to use with GitHub

> git init
> git status

Local graphic

Name the primary branch main

> git branch -M main
> git status

Notice:

Specify which files that you want to transfer

Use the git add command to specify exactly which files you want to transfer to GitHub.

> git status
> git add silly_file.txt
> git status

Notice:

Save the changes

 > git commit

Alternatively, you can commit directly from the command line:

 > git commit -m "add silly file"
> git status

What’s in a commit message?

Connect the repo to GitHub


> git remote -v
> git remote add origin git@github.com:kelle/silly_repo.git
> git remote -v

Upload the repo contents to GitHub

 
> git push origin main

Push to remote graphic

Check GitHub

silly_file.txt should now be in the repo on the GitHub website.

Push to remote graphic

Questions?

Push to remote graphic

Activity

Troubleshooting

Octocat buddies

Troubleshooting

github status screenshot

https://medium.com/@kenwarner/command-line-ux-matters-too-improve-your-git-status-colors-170de858953d

Troubleshooting

github status screenshot

Tomorrow

Using GitHub to collaborate

Push to the fork graphic

Survey

http://bit.ly/sciware-github1-2022