class: center, middle, inverse, title-slide # Collaborating with Git & Github ### Justin Post --- layout: true --- # 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: + Pull down most recent files (`git pull`) or do initial download (`git clone`) + Add files you want to keep changes to (`git add`) + Commit to the changes (`git commit`) + Push the changes to the remote repo (`git push`) --- # Collaboration Idea - Everyone can work on the same `branch` and just take turns working <img src="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="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="img/forkcommit.png" width="45%" 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="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="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="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="img/pullcheck2.png" width="70%" style="display: block; margin: auto;" /> --- # Dealing with conflicts - Sometimes changes requested conflict with changes already made <img src="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="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="img/resolve2.png" width="70%" style="display: block; margin: auto;" /> - Figure out what to do and delete the `<<< === >>>` lines