Make sure Git and GitHub are installed - see the Create GitHub account and Install Git sections of my tutorial
Create a repository on GitHub target. Always add a README and think about a license.
Clone the repo to R Studio.
Save this file to that repository and commit and push changes.
Add collaborator.
Collaborator clones repo to R Studio.
I make a change, commit, and push.
I am making a change.
Collaborator pulls changes, makes a new change, commits, and pushes.
Hello I am Lisa’s sister :-)
I pull in change.
Uh oh, we don’t communicate and both try to make changes to the document at the same time -> merge conflict! Show how to resolve.
We could keep working in that way. Or, we could add branches. Show how to add a branch in R by clicking on the “branch” in the Git tab (next to settings). Show how it also changes on GitHub.
Make a change to the file in a branch (a small change - like some words) and commit and push. Show what shows up in GitHub (pull request - go through and merge and delete branch). Pull changes back to R Studio.
Add a new branch. Make a harder change, commit, and push. You may run into changes that need resolving.
Show creating and issue and using branching/PR to solve issue and close issue.
I saved a file but don’t want the changes I just made. You can right click on the file and choose revert. You could also choose diff to see how it has changed from its last version.
Oh shoot (or maybe a worse word), I didn’t mean to commit that! (or I can’t push what I just committed). We need to move to the command line in the terminal. When there, use git reset HEAD~1. This will bring back all the things you committed - so you can delete them if you really don’t want them at all or edit at will and recommit.
I did it again! But now I’ve pushed it! How do I fix this? We can go back to a previous commit by using git revert <SHA> in the terminal, where <SHA> is the alpha numeric string that defines that commit. This actually adds another commit (see this resource). You may end up with a merge conflict, which you will need to resolve (I’d recommend doing that inside of R Studio) and if you end up in a place with a bunch of #### symbols in the terminal, type :q to get out.