sciware

Sciware

Intro to GitHub

https://sciware.flatironinstitute.org/33_SummerIntro

Sciware 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

Sciware website

Previous sciwares available here https://sciware.flatironinstitute.org

Password for videos is…

Getting help

Today’s Agenda

Collaborating on GitHub

Collaborating with others

Forking Workflow

  1. Fork the repository on github
  2. Clone your new fork from github to local
  3. Make changes to the code
  4. Push to your fork
  5. Open a Pull Request (PR) from your fork to the upstream repo
  6. Wait for upstream to approve and merge your changes
  7. Keep your fork up to date

Step 0: A clean start


> mv sciware33-git-intro/ sciware33-git-intro-day1/

Step 1: Fork

<img width=80% src=”./assets/Learn-Git-Graphics/Forking%20a%20Repo.png”>

Step 1: Fork

First we need to fork the repo https://github.com/flatironinstitute/sciware33-git-intro

Step 2: Clone

<img width=80% src=”./assets/Learn-Git-Graphics/Clone%20the%20Fork.png”>

Step 2: Clone

Next, we clone our fork of the repo:


> git clone git@github.com:your_user_name/sciware33-git-intro.git

Step 3: Add Your Code


> cd student_info/
> nano

Step 3: Add Your Code

Example contents of robert_blackwell.csv:

    
Name,Center,Research Focus,Fun Fact
Robert Blackwell,SCC,high performance computing,violin!
    

Save the file.

Step 4: Push to Your Fork

<img width=80% src=”./assets/Learn-Git-Graphics/Push%20to%20the%20Fork.png”>

Step 4: Push to Your Fork


       > git status

> git add student_info/robert_blackwell.csv
> git commit -m "Adding info for Robert Blacwell"

   > git push origin main

Break

Step 5: Open a Pull Request

Step 5: Open a Pull Request

Step 5: Open a Pull Request

PR Case Study

Here’s an example of a PR without a helpful description:

PR Case Study

Here’s an example of a PR with a helpful description:

<img height=70% width=60% src=”./assets/pr_case_study_good.png”>

Step 5: Open a Pull Request

Things to think about when making pull requests (PR):

Step 5: Open a Pull Request

Finish up your pull request and click “Create Pull Request”

Step 6: Wait for your PR to be merged

Someone else will merge your PR.

In practice, someone might leave comments on your PR and/or request changes before merging.

Reviewing a Pull Request

As other folks make PRs, go to the pull requests tab on GitHub.

Reviewing a Pull Request

Choose another student’s PR and click on it.

Click on the commit to see the diff of their changes and hover over a line until you see the + symbol.

Step 7: Pull Other’s Changes

<img width=80% src=”./assets/fetch-upstream-3.png”>

Step 7: Pull Other’s Changes to your Fork

Sync.

<img width=80% src=”./assets/fetch-upstream-1.png”>

Step 7: Pull Other’s Changes to your Fork (Sync)

Sync.

<img width=80% src=”./assets/fetch-upstream-4.png”>

Step 8: Pull Other’s Changes to your Local


    > git pull origin main

Step 8: Pull Other’s Changes to your Local

Confirm that you have the changes locally.


      > git log
      > ls student_info/
    

Advanced: Branching

Create a local branch

> git branch -v
> git checkout -b newbranch
> git branch -v
> git checkout main

Make a commit on a branch

Open a PR

Merge into main

> git branch -v
> git checkout main
> git merge newbranch
> git push origin main

Check your new PR!

Extra Resources

Check out and bookmark these tutorials for more information about git and the forking workflow:

Survey