Session 6
September 19, 2024
Word Bank
repo | commit | remote | push | pull | add
git
___ is used to tell git to track a filegit
____ is used to synchronize changes on your computer with a remoteWhat difficulties did you have while putting your repo on GitHub?
Everyone practice cloning this example repo as a new RStudio project: https://github.com/cct-datascience/demo-repo-2024 1
Need one volunteer to edit the README.md and practice commit + push
What happens when two people make conflicting edits to a file and push them?
Creates a merge conflict
git pull
These are alternative ways to deal with conflicts—we won’t get into the details
For now, we recommend you stick with the “merge” option
Resolve the conflict however you want (i.e. keep one of the two sections)
Delete all lines with <<<<<<<
, >>>>>>>
, or =======
Save and commit
Each person works on a “branch”—an independent series of commits that can be merged back into the “main” branch.
Make a new branch using RStudio’s Git pane (for this demo, use your name)
Make some edits (e.g. to README.md), save, add, commit.
You can go back to the “main” version of your project at any time.
Push your branch to GitHub
View changes on GitHub
A request to merge changes into the main branch
Need another volunteer to share screen and be guided through making a pull request
This time, everyone can follow along!
What if you don’t have permission to push to a GitHub repo but you want to contribute?
Make a fork!
To contribute to a repo you don’t have push permission for:
Tip
Learn more, including handy usethis
shortcuts: https://happygitwithr.com/fork-and-clone
Exercise
In pairs, practice forking and cloning a demo repo you do not have permission to push to: https://github.com/cct-datascience/demo-repo-fork-2024.
Make a new branch, make commits, and make a pull request to the upstream repo.
#git channel in UA Data Science Slack
For the next update to your colloquium project, practice using a branch and and pull request on GitHub
Clone a repo you do not have permission to push to without forking it and see what happens when you try to use git push
Fork and clone a repo on GitHub to explore it (e.g. a lab mate’s code, a research compendium, your favorite R package)