name: inverse layout: true class: center, middle, inverse
layout: false
- Why do I need git?
- Introduction to git and GitHub
- How do we use git?
- Hands-on workshop
-
Code History
- no more
script_final.R
,script_finalDEF.R
,script_finalDEFV2.R
- no more
-
Reverting changes
- rolling back to an earlier, working version
-
Collaborating with colleagues
- sharing code without difficult merges and usb-sticks
-
Code review
- check each other's code to guarantee code quality
- Version Control System
- Managing plain text files (R syntax, Matlab files, source code, txt files)
- Managing microsoft office documents
- Storing data
???
- Git is a version management system, which means that it can keep track of earlier versions of your source code / documents.
- With plain text files we mean anything that is readable from notepad (generally source code or simple files). Not binaries.
.pull-left[
- Repositories
- Clone
- Pull
- Add
- Commit
- Push
- Branches and pull-requests ]
--
.pull-right[
- Checkouts
- Rebasing
- Cherry-picking
- Tags
- Forks ]
??? Each of these will be covered in more detail. The items on the right are added for reference only.
- (Cloud hosted) remote location containing your code
- GitHub is a provider of hosted git repositories
- Repository can be either private (just for you) or public (for everyone)
???
- Downloading a remote repository to your local machine
- Only needed once per repository, per machine you need to access your code on
- Updating your local working copy with the latest version from the git provider
- Do this every time you want to pull in changes from the remote repository
- Selecting files / changes that you would like to store in git
- You will have to do this every time you want to store changes or files
??? Git follows multiple steps in order to sync your code to a remote repository. It starts with actually selecting which files you'd like to synchronize.
- With a commit you can combine all the staged files into a single update
- A commit comes with a commit message. In these messages you can write what you changed and why you changed something
??? With a git commit you actually combine your changes into a single sort of package, to which you provide a useful name.
- With a push you upload your commits to the git provider (in our case GitHub)
- You have to push in order to share your commits with everyone.
??? Finally you push your local commits to a remote repository, to store them or to share them with the world.
Supposed to be the stable version of the code.
Moment to review code before merging it to master.
A pull request causes the change to be merged into master.
- Clone a repository.
- Create a new branch.
- Make changes in that branch and add / commit / push to GitHub.
- Create a pull request and ask others to review the changes.
- If changes are ok, merge the branch into master.
- Git has a powerful command line interface
- You can use public / private key SSH keys instead of using a username and password
- GitHub can be combined with various services for automatically performing running tests on the code in GitHub (e.g., CircleCI)
layout: false
- Open https://uwp.rug.nl and login
- Click on Workspace desktop
- When you are logged in, start the Google Chrome browser
- All the next steps should be performed from within the UWP client.
- Log in on https://github.com
- Click on the green New button next to Repositories
- Fill in a name for the repository
- Description is not necessary
- Make it a public repository
- No need to initialize it with anything
- Click on Create repository
- Click on the clipboard button to copy the repository url.
- Go to https://git-scm.com/download/win and download the installer.
- Keep clicking next until it starts installing.
- Open the Windows start menu, type:
R studio
- In R Studio, Open the Tools menu and select Global options
- Go to Git/SVN
- Browse to the correct git executable (e.g. C:/Users/pnumber/AppData/Local/Programs/Git/bin/git.exe)
- Click OK
- Close R Studio
- Open R Studio again
- Go to File and select New project
- Select Version control
- Click on Git
- Paste the repository URL
- (optional) change the directory to store the code in
- Click on Create Project
- Go to File, New File, R Script
- Add some simple R code, e.g.,
print(2 + 2)
- Save and choose a filename ending in .R
- Click on the tab named git (right side)
- Click the Diff button to see an overview of the changes
- Check all changed files to add them to the staging area (could take some time)
- Add a descriptive commit message and click commit
- Press close when the commit is done
- Now press push to upload the changes to GitHub
- Fill out your username and password
???
- Altijd eerst een diff doen!
- Username and password worden bewaard ie voor de session, dus dat is wel hip