The Turing Way Community. This illustration is created by Scriberia with The Turing Way community, used under a CC-BY 4.0 licence. DOI: 10.5281/zenodo.3332807
Git and GitHub
installed on local computer
tracks changes to files
separate versions
central, remote storage of files
everyone can contribute changes
changes can be combined and shared
We can leverage the interplay between both to help us share code and collaborate with others!
Basic Git/Github Workflow
Remote repository on Github
Where all of your code and related files lives online
Central location where everyone is sharing their changes
Connect the remote repository to the files on your local computer
git clone
git init
Local repository
Files kept on your local computer
Includes branches from the remote repository
allows for different versions of the same file
Different from local working directory
Making changes locally
Commits
groups of small, meaningful changes
snapshots of your repository at that time
tell a story of the history of your repository
Commits
Make a commit in 2 stages:
save your changes locally and then stage the files you want to commit
git add <FILENAME>
commit your changes
git commit -m "descriptive commit message"
Push
To sync the changes you’ve made locally with the remote repository, you need to “PUSH” your commits
git push
Pull
To sync any changes that were made to the remote repository onto your local computer you need to “PULL” commits
2 ways:
1. git pull
git fetch, then eventually git merge
Branches
The default for all repositories is main
Pull Requests
Once you have finished development on your branch and want to add your changes to the main branch, you can submit a pull request
Live Demo
Let’s make our first commit!
Activity 1
Following the template provided here, create a new Markdown document with:
A list of everyone in your group, including:
their affiliation
their GitHub name
a picture of a species you work on
a code chunk with your most used function
a task list of three things you would like to learn from the workshop
Save the file with a new name.
Commit your file, and push to the repository.
Activity 2: Branches
Create a new branch from the main branch
Add your name to the list of participants.
Save your change, commit, and push to your branch.
Submit a Pull Request to merge your changes into main branch.