layout: false class: title-slide-section-red, middle # Basics of Using `git` & `gitHub` Justin Post --- layout: true <div class="my-footer"><img src="data:image/png;base64,#img/logo.png" alt = "" style="height: 60px;"/></div> --- # Workflow Important considerations for data analysis workflow: - **Reproducibility** <br> <br> <br> - **Version control** <br> <br> <br> - **Collaboration** --- # What are git and github? - **Git** is a version control software - **Github** is an online hosting service for Git-based projects --- # What are git and github? - **Git** is a version control software - **Github** is an online hosting service for Git-based projects ## Git Tracking - You associate git with a folder (repo) - Git keeps track of all files in the folder (repo) - If you want to keep changes you've made, you **commit** and **push** the changes to the folder (repo) --- # Github - Github allows you to have a remote file repository (folder) tracked by git + Let's create a repository on github.com + **Add** some files and **commit** to the changes + Modify some files on github + Investigate the version control! --- # Local vs Remote Work Mostly we'll be working on Google Colab for now. If we were working on our local machine, we'd need to install `git` on our computer! - When we get to working on our local `JupyterHub`, we'll just use the web-based interface with `gitHub`. - Next, let's talk about how we'd collaborate using `git` and `gitHub` --- # Collaboration Idea - Everyone can work on the same `branch` and just take turns working <img src="data:image/png;base64,#img/git_diagram.png" width="500px" style="display: block; margin: auto;" /> --- # Working on Branches - Alternatively, you can have separate **branches** of the repo <img src="data:image/png;base64,#img/git_branch_diagram.png" width="500px" style="display: block; margin: auto;" /> - Work on a branch is similar to working on the main branch - Can merge when happy! --- # Forking - People often `fork` the repo - This creates a copy of the repo on your account - You can then work as normal - If you do a commit on your branch, you may notice something like this <img src="data:image/png;base64,#img/forkcommit.png" width="45%" style="display: block; margin: auto;" /> --- layout: false # Merging Branches Suppose you like your commit and you think the original owner will too! - You can do a `pull` request <img src="data:image/png;base64,#img/pullrequest.png" width="79%" style="display: block; margin: auto;" /> --- # Merging Branches Suppose you like your commit and you think the original owner will too! - You can do a `pull` request <img src="data:image/png;base64,#img/pullinfo.png" width="75%" style="display: block; margin: auto;" /> --- # Merging Branches If you are lucky, there won't be any merge conflicts. - Allows the owner of the original repo to accept the pull request without needing to modify things - The owner will get a notification that a pull request has been made <img src="data:image/png;base64,#img/pullrequestnoted.png" width="45%" style="display: block; margin: auto;" /> --- # Merging Branches Owner can then investigate the request and choose whether or not to accept it or they can ask for more details <img src="data:image/png;base64,#img/pullcheck2.png" width="70%" style="display: block; margin: auto;" /> --- # Dealing with conflicts - Sometimes changes requested conflict with changes already made <img src="data:image/png;base64,#img/mergeconflict.png" width="70%" style="display: block; margin: auto;" /> --- # Dealing with conflicts Owner sees a notification about conflicts that must be resolved <img src="data:image/png;base64,#img/resolve.png" width="70%" style="display: block; margin: auto;" /> --- # Dealing with conflicts They can view the issues and pick which to include or to include both with a modification `<<<<<<<` is a conflict marker <img src="data:image/png;base64,#img/resolve2.png" width="70%" style="display: block; margin: auto;" /> - Figure out what to do and delete the `<<< === >>>` lines --- # Recap - **Git** is a version control software + Associated with a folder (repo) + Tracks changes to files - **Github** is an online hosting service for Git-based projects - Workflow: + Create a repo on `gitHub` + Open `.ipynb` files in Colab + Save a copy on `gitHub`!