SlideShare a Scribd company logo
Using Git within RStudio
Paulina Jedynak, PhD
github.com/paujedynak
Environmental Epidemiology lab
gricad-gitlab.univ-grenoble-alpes.fr
1
May 2021
Using Git within RStudio
This demo will be based on Windows OS and GitHub platform but do not worry – most of the procedures are
common for different systems and platforms
2
Using Git within RStudio
After this workshop you should be able to:
• Install all the necessary software to use Git version control with RStudio
• Configure Git to communicate with an online repository (e.g. GitHub)
• ‘Stage’, ‘commit’, ‘push’ and ‘pull’ your code to the online repository
More details on each step discussed here you will find at: happygitwithr.com
If you prefer less details but straight to the poing, try cfss.uchicago.edu/setup/git-with-rstudio
3
This demo will be based on Windows OS and GitHub platform but do not worry – most of the procedures are
common for different systems and platforms
1. Initial installations
Source: https://happygitwithr.com
4
1. Initial installations
1. Install or upgrade RStudio
5
1. Initial installations
1. Install or upgrade RStudio
2. Register an online account where the ‘remote’ version of your repositories will be kept. As an
example I will use the GitHub platform but several other platforms exist
• github.com
• gitlab.com
• gricad-gitlab.univ-grenoble-alpes.fr (login with AGALAN credentials)
• …
NOTE: Git != GitHub
6
7
Can be easily changed at any time
1. Install or upgrade RStudio
2. Register an online account where the ‘remote’ version of your repositories will be kept. As an
example I will use the GitHub platform but several other platforms exist
3. Install Git software on your machine (accept the default setup options!)
git-scm.com/downloads
You can check if you already have Git by typing where.exe git (Windows)
or which git (Mac, Linux) in the shell
1. Initial installations
8
1. Install or upgrade RStudio
2. Register an online account where the ‘remote’ version of your repositories will be kept. As an
example I will use the GitHub platform but several other platforms exist
3. Install Git software on your machine (accept the default setup options!)
git-scm.com/downloads
You can check if you already have Git by typing where.exe git (Windows)
or which git (Mac, Linux) in the shell
4. Open RStudio
1. Initial installations
9
1. Initial installations
Restart/ reopen RStudio!!
10
1. Initial installations
Make sure the RStudio “sees” Git (in Windows, after installation Git should be recognized automatically)
11
1. Initial installations
Make sure the RStudio “sees” Git (in Windows, after installation Git should be recognized automatically)
If this field is empty you need to provide the
location of the git.exe file. To find it
type where.exe git (Windows)
or which git (Mac, Linux) in the shell
1. Initial installations
Make sure the RStudio “sees” Git (in Windows, after installation Git should be recognized automatically)
If this field is empty you need to provide the
location of the git.exe file. To find it
type where.exe git (Windows)
or which git (Mac, Linux) in the shell
Restart/ reopen RStudio!!
2. Introduce yourself to Git
14
2. Introduce yourself to Git
This does not have to be your GitHub user name
This must be the email associated with GitHub account
2. Introduce yourself to Git
You may check whether Git understood what you typed by using the command
git config --global –list (again in the shell)
3. Connect to GitHub
1. Go to https://github.com and make sure you are logged in
2. Click green “New” button. Or, if you are on your own profile page, click first on “Repositories”, then click the
green “New” button
17
3. Connect to GitHub
1. Go to https://github.com and make sure you are logged in
2. Click green “New” button. Or, if you are on your own profile page, click first on “Repositories”, then click the
green “New” button
18
3. Connect to GitHub
1. Go to https://github.com and make sure you are logged in
2. Click green “New” button. Or, if you are on your own profile page, click first on “Repositories”, then click the
green “New” button
How to fill this in:
1. Repository name: e.g. test
1
19
3. Connect to GitHub
1. Go to https://github.com and make sure you are logged in
2. Click green “New” button. Or, if you are on your own profile page, click first on “Repositories”, then click the
green “New” button
How to fill this in:
1. Repository name: e.g. test
2. Description: optional but useful 1
2
20
3. Connect to GitHub
1. Go to https://github.com and make sure you are logged in
2. Click green “New” button. Or, if you are on your own profile page, click first on “Repositories”, then click the
green “New” button
How to fill this in:
1. Repository name: e.g. test
2. Description: optional but useful
3. Choose visibility: public or private*
1
2
3
*Up to 3 collaborators
21
3. Connect to GitHub
1. Go to https://github.com and make sure you are logged in
2. Click green “New” button. Or, if you are on your own profile page, click first on “Repositories”, then click the
green “New” button
How to fill this in:
1. Repository name: e.g. test
2. Description: optional but useful
3. Choose visibility: public or private*
4. Optional: add README if needed;
add .gitignore file** with R template
1
2
3
4
*Up to 3 collaborators
**Enables ‘hiding’ some files from being
traced by Git 22
3. Connect to GitHub
1. Go to https://github.com and make sure you are logged in
2. Click green “New” button. Or, if you are on your own profile page, click first on “Repositories”, then click the
green “New” button
How to fill this in:
1. Repository name: e.g. test
2. Description: optional but useful
3. Choose visibility: public or private*
4. Optional: add README if needed;
add .gitignore file** with R template
5. Click green button “Create repository”
1
2
3
4
*Up to 3 collaborators
**Enables ‘hiding’ some files from being
traced by Git 5 23
3. Connect to GitHub
24
3. Connect to GitHub
25
3. Connect to GitHub
1. Click the Code button
26
1. Click the Code button
2. Copy the link from the HTTPS tab to your Clipboard
27
1. Click the Code button
2. Copy the link from the HTTPS tab to your Clipboard
28
IF YOU CANNOT FIND THE ‘CODE’ BUTTON, DON’T PANIC!
It means you created an empty repository (without
README, .gitignore or any other file). As soon you add a file
to the repo (e.g. README), the button will appear
4. Clone the repo to your local machine
Now you have 2 options depending if you are starting a new R Project or you already have an existing R Project
that you want to connect with Git
29
4. Clone the repo to your local machine
Brand new R Project:
1. In RStudio >> File >> New Project…
2. Choose Version Control
3. Choose Git
4. Paste the link to your repository into
the Repository URL field (the Project
directory name will be filled
automatically)
5. Click Browse… to choose the location
where your new Project will be created
6. Click Create Project
30
4. Clone the repo to your local machine
31
Brand new R Project:
1. In RStudio >> File >> New Project…
2. Choose Version Control
3. Choose Git
4. Paste the link to your repository into
the Repository URL field (the Project
directory name will be filled
automatically)
5. Click Browse… to choose the location
where your new Project will be created
6. Click Create Project
4. Clone the repo to your local machine
You can commit, push and pull…
32
Brand new R Project:
1. In RStudio >> File >> New Project…
2. Choose Version Control
3. Choose Git
4. Paste the link to your repository into
the Repository URL field (the Project
directory name will be filled
automatically)
5. Click Browse… to choose the location
where your new Project will be created
6. Click Create Project
5. Connect Git to an existing R project
Existing R Project:
1. Open an existing Project
33
Existing R Project:
1. Open an existing Project
2. Tools >> Version Control >> Project Setup…
3. Choose Git as Version control system
4. Accept the following prompts
5. Connect Git to an existing R project
34
At this stage your version control works only locally
(it is not connected with an online repository) –
you may want to keep it like this or you may want
to link it to the remote repository
5. Connect Git to an existing R project
35
Existing R Project:
1. Open an existing Project
2. Tools >> Version Control >> Project Setup…
3. Choose Git as Version control system
4. Accept the following prompts
Connect to an online repository:
1. Create a remote repository as explained
earlier in this presentation (3. Connect to
GitHub). IMPORTANT: repo name must
match your existing Project name
2. Copy the repo link to your Clipboard
5. Connect Git to an existing R project
36
Connect to an online repository:
1. Create a remote repository as explained
earlier in this presentation (3. Connect to
GitHub). IMPORTANT: repo name must
match your existing Project name
2. Copy the repo link to your Clipboard
3. Add remote URL to your existing Project
using shell by typing:
4. Check the remote URL using shell by typing:
5. Connect Git to an existing R project
37
git remote add origin https://github.com/username/reponame.git
where username is your GitHub username and reponame is your GitHub repository name
git remote -v
Connect to an online repository:
1. Create a remote repository as explained
earlier in this presentation (3. Connect to
GitHub). IMPORTANT: repo name must
match your existing Project name
2. Copy the repo link to your Clipboard
3. Add remote URL to your existing Project
using shell by typing:
4. Check the remote URL using shell by typing:
5. Connect Git to an existing R project
38
git remote -v
Connect to an online repository:
1. Create a remote repository as explained
earlier in this presentation (3. Connect to
GitHub). IMPORTANT: repo name must
match your existing Project name
2. Copy the repo link to your Clipboard
3. Add remote URL to your existing Project
using shell by typing:
4. Check the remote URL using shell by typing:
5. Connect Git to an existing R project
39
git remote -v
IF THIS FIELD IS EMPTY OR ‘PUSH’ AND ‘PULL’ BUTTONS ARE
GREYED OUT (INACTIVE), DON’T PANIC!
Restart / reopen RStudio. If the problem persists, make
some commit and make a push setting the upstream by
typing in the shell:
git push origin master -u
Connect to an online repository:
1. Create a remote repository as explained
earlier in this presentation (3. Connect to
GitHub). IMPORTANT: repo name must
match your existing Project name
2. Copy the repo link to your Clipboard
3. Add remote URL to your existing Project
using shell by typing:
4. Check the remote URL using shell by typing:
5. Connect Git to an existing R project
40
git remote -v
You can commit, push and pull…
41
6. Commit, push and pull
MAKE A COMMIT every time you finish a valuable
chunk of work, probably many times a day
42
6. Commit, push and pull
• All files within the Project are
‘observed’ by Git, unless added to
the .gitignore file
• If there are any changes in the
Project – new files created
(new_script.R), any SAVED changes
made to the content of existing
files (README.md) etc., Git will
keep notifying you and will let you
decide if to start tracking them
(new files) or commit changes
(modified files)
43
6. Stage, commit, push and pull
Git informes you that new files appeared in the Project (? ? = ‘unknown’ status)
CREATING NEW FILES, MODYFYING EXISTING ONES
44
6. Stage, commit, push and pull
Git informes you that new files appeared in the Project (? ? = ‘unknown’ status)
Git informes you that changes were made to a file (M = ‘modified’ status)
CREATING NEW FILES, MODYFYING EXISTING ONES
45
6. Stage, commit, push and pull
Git informes you that new files appeared in the Project (? ? = ‘unknown’ status)
Git informes you that changes were made to a file (M = ‘modified’ status)
• By ticking files you stage them (it is a necessary step before a commit) so you let
Git know which files will be included in your next commit
• By staging a new file (new_script.R) you let Git know you want it to start tracking
this file (A = ‘adding for tracking’ status)
• By staging a modified file (README.md) you let Git know you want to capture the
file content modification
STAGING
CREATING NEW FILES, MODYFYING EXISTING ONES
46
6. Stage, commit, push and pull
Git informes you that new files appeared in the Project (? ? = ‘unknown’ status)
Git informes you that changes were made to a file (M = ‘modified’ status)
• By ticking files you stage them (it is a necessary step before a commit) so you let
Git know which files will be included in your next commit
• By staging a new file (new_script.R) you let Git know you want it to start tracking
this file (A = ‘adding for tracking’ status)
• By staging a modified file (README.md) you let Git know you want to capture the
file content modification
• After you staged all the files, click ‘Commit’ button
STAGING
CREATING NEW FILES, MODYFYING EXISTING ONES
47
6. Stage, commit, push and pull
COMMIT
• A new window pops-out where you need to
provide an informative description of the
commit (Commit message) so in the future
you can easily find the commit by name
• No need to include date in the commit, it is
automatically dated
48
6. Stage, commit, push and pull
COMMIT
• A new window pops-out where you need to
provide an informative description of the
commit (Commit message) so in the future
you can easily find the commit by name
• No need to include date in the commit, it is
automatically dated
• Clicking on a staged file (README.md) we
can see the changes (‘diff’) made in the file
(deleted lines in red, modified/new lines in
green)
• Clicking ‘Commit’ button captures an image
of the code in a particular time point
49
6. Stage, commit, push and pull
COMMIT
• A new window pops-out where you need to
provide an informative description of the
commit (Commit message) so in the future
you can easily find the commit by name
• No need to include date in the commit, it is
automatically dated
• Clicking on a staged file (README.md) we
can see the changes (‘diff’) made in the file
(deleted lines in red, modified/new lines in
green)
• Clicking ‘Commit’ button captures an image
of the code in a particular time point
50
6. Stage, commit, push and pull
PUSH
• After the commit, the staged files disappear
51
6. Stage, commit, push and pull
PUSH
• After the commit, the staged files disappear
• You are also informed that your local
repository is ahead of the remote one by
one commit (your local version is newer than
the online one by one commit)
• You do not need to push each time you make
a commit, you can do it e.g. at the end of the
day
52
6. Stage, commit, push and pull
PUSH
• After the commit, the staged files disappear
• You are also informed that your local
repository is ahead of the remote one by
one commit (your local version is newer than
the online one by one commit)
• You do not need to push each time you make
a commit, you can do it e.g. at the end of the
day
• To push your code to the online repository,
click on the green ‘Push’ button
53
6. Stage, commit, push and pull
PULL
• If you want to e.g. synchronize your work
between machines (e.g. your computer at work
and another one at home; your machine and
your colleague’s machine who works with you
on a project, etc.), on the machine where the
work is outdated, click the blue ‘Pull’ button
• Pulling will ‘download’ new versions of your
tracked files and replace/ merge with the old
ones
54
6. Stage, commit, push and pull
PULL
• If you want to e.g. synchronize your work
between machines (e.g. your computer at work
and another one at home; your machine and
your colleague’s machine who works with you
on a project, etc.), on the machine where the
work is outdated, click the blue ‘Pull’ button
• Pulling will ‘download’ new versions of your
tracked files and replace/ merge with the old
ones
• Do not worry (too much) about overwriting
some important files – Git will inform you if
there are any conflicts
• If you work on several machines and do Push
and Pull frequently, get used to starting your
work by making a Pull (you will avoid conflicts)
55
6. Stage, commit, push and pull
56
6. Stage, commit, push and pull
History
57
7. Reversing a commit (or peeking to the history)
58
*revert != reset != checkout… (the most confusing part of Git)
The need to revert the changes in the code in a particular way will be specific for the working
environment (e.g., if you need to get the last working version in the matter of hours/minutes –
common in big scale production setups; if you work alone or with several developers of the
same code, etc.)
7. Reversing* a commit (or peeking to the history)
Undoing things: basic level git-scm.com/book/en/v2/Git-Basics-Undoing-Things
Undoing things: level pro git-scm.com/book/en/v2/Git-Tools-Reset-Demystified
59
The most common scenarios when I go back in time:
1. Reversing the code to its version in the particular
point in the past
Happens very rarely (once per project and rather
towards its end, when the code is close to its final
version)
2. Peeking in previous versions of the code to retrieve
specific function or chunk of code
Happens frequently (several times per project, at any
development stage)
7. Reversing a commit (or peeking to the history)
60
The most common scenarios when I go back in time:
2. Peeking in previous versions of the code to retrieve
specific function or chunk of code
Happens frequently (several times per project, at any
development stage) –> GoogleDocs version history
7. Reversing a commit (or peeking to the history)
61
The most common scenarios when I go back in time:
7. Reversing a commit (or peeking to the history)
You may restore the old version of the
script, in the same form as it was in the
past (.R, .Rmd, .html…) and copy paste
the chunk of code or save the entire
script (but if you want to save the old file
and use it to replace the never files – do
not go there, reversing a commit is the
tool you need!)
62
Summary
• Git is a great tool if you want to share work within projects (e.g. several persons committing to the same project – NO
MORE SENDING CODE BY EMAIL!!!)
• Different collaborators (or your different machines) have the same version of the code plus they have access to all the
changes made by any user (or by you in different time points)
• Ideally, when using Git, you should be consequent: make frequent commits that are named in an informative way and
contain logically linked chunks of work. At the beginning it may not be easy, but it pays off
• Using Git allows you to reverse an error/ retrieve deleted files or chunks of code relatively easily (the more disciplined
you are, the easier it becomes)
• The longer you work with Git, the less often you discover that all the files disappeared from your workspace and you
have no idea where they went. At the end, in the 90% of cases they reappear 
Thank you for your attention
Paulina Jedynak, PhD
github.com/paujedynak
paulina.jedynak@gmail.com
Environmental Epidemiology lab
gricad-gitlab.univ-grenoble-alpes.fr
63

More Related Content

What's hot

Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Beginner's guide to git and github
Beginner's guide to git and github Beginner's guide to git and github
Beginner's guide to git and github
SahilSonar4
 
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris WanstrathInside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
SV Ruby on Rails Meetup
 
Github
GithubGithub
Dev-Jam 2019 - Developing & Contributing to OpenNMS
Dev-Jam 2019 - Developing & Contributing to OpenNMSDev-Jam 2019 - Developing & Contributing to OpenNMS
Dev-Jam 2019 - Developing & Contributing to OpenNMS
Ronny Trommer
 
Web Programming - Git basics
Web Programming - Git basicsWeb Programming - Git basics
Web Programming - Git basics
Ömer Taşkın
 
Intro to git (UT biocomputing 2015)
Intro to git (UT biocomputing 2015)Intro to git (UT biocomputing 2015)
Intro to git (UT biocomputing 2015)
chenghlee
 
Git
GitGit
How to install and use git
How to install and  use gitHow to install and  use git
How to install and use git
Faysal Hossain Shezan
 
My Notes from https://www.codeschool.com/courses/git-real
My Notes from  https://www.codeschool.com/courses/git-realMy Notes from  https://www.codeschool.com/courses/git-real
My Notes from https://www.codeschool.com/courses/git-real
Eneldo Serrata
 
Effective Git with Eclipse
Effective Git with EclipseEffective Git with Eclipse
Effective Git with Eclipse
Chris Aniszczyk
 
Github
GithubGithub
Git
GitGit
Using Git Inside Eclipse, Pushing/Cloning from GitHub
Using Git Inside Eclipse, Pushing/Cloning from GitHubUsing Git Inside Eclipse, Pushing/Cloning from GitHub
Using Git Inside Eclipse, Pushing/Cloning from GitHub
AboutHydrology Slides
 
Git & Github Workshop - Le Wagon Melbourne
Git & Github Workshop - Le Wagon MelbourneGit & Github Workshop - Le Wagon Melbourne
Git & Github Workshop - Le Wagon Melbourne
Paal Ringstad
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
Git Basics - RubyFest 2009
Git Basics - RubyFest 2009Git Basics - RubyFest 2009
Git Basics - RubyFest 2009
Ariejan de Vroom
 
TinkerPop and Titan from a Python State of Mind
TinkerPop and Titan from a  Python State of MindTinkerPop and Titan from a  Python State of Mind
TinkerPop and Titan from a Python State of Mind
Denise Gosnell, Ph.D.
 
Git and Github workshop
Git and Github workshopGit and Github workshop
Git and Github workshop
Otto Kekäläinen
 
Git and GitHub - The beginning
Git and GitHub - The beginning Git and GitHub - The beginning
Git and GitHub - The beginning
Gemma Catolino
 

What's hot (20)

Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Beginner's guide to git and github
Beginner's guide to git and github Beginner's guide to git and github
Beginner's guide to git and github
 
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris WanstrathInside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
 
Github
GithubGithub
Github
 
Dev-Jam 2019 - Developing & Contributing to OpenNMS
Dev-Jam 2019 - Developing & Contributing to OpenNMSDev-Jam 2019 - Developing & Contributing to OpenNMS
Dev-Jam 2019 - Developing & Contributing to OpenNMS
 
Web Programming - Git basics
Web Programming - Git basicsWeb Programming - Git basics
Web Programming - Git basics
 
Intro to git (UT biocomputing 2015)
Intro to git (UT biocomputing 2015)Intro to git (UT biocomputing 2015)
Intro to git (UT biocomputing 2015)
 
Git
GitGit
Git
 
How to install and use git
How to install and  use gitHow to install and  use git
How to install and use git
 
My Notes from https://www.codeschool.com/courses/git-real
My Notes from  https://www.codeschool.com/courses/git-realMy Notes from  https://www.codeschool.com/courses/git-real
My Notes from https://www.codeschool.com/courses/git-real
 
Effective Git with Eclipse
Effective Git with EclipseEffective Git with Eclipse
Effective Git with Eclipse
 
Github
GithubGithub
Github
 
Git
GitGit
Git
 
Using Git Inside Eclipse, Pushing/Cloning from GitHub
Using Git Inside Eclipse, Pushing/Cloning from GitHubUsing Git Inside Eclipse, Pushing/Cloning from GitHub
Using Git Inside Eclipse, Pushing/Cloning from GitHub
 
Git & Github Workshop - Le Wagon Melbourne
Git & Github Workshop - Le Wagon MelbourneGit & Github Workshop - Le Wagon Melbourne
Git & Github Workshop - Le Wagon Melbourne
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git Basics - RubyFest 2009
Git Basics - RubyFest 2009Git Basics - RubyFest 2009
Git Basics - RubyFest 2009
 
TinkerPop and Titan from a Python State of Mind
TinkerPop and Titan from a  Python State of MindTinkerPop and Titan from a  Python State of Mind
TinkerPop and Titan from a Python State of Mind
 
Git and Github workshop
Git and Github workshopGit and Github workshop
Git and Github workshop
 
Git and GitHub - The beginning
Git and GitHub - The beginning Git and GitHub - The beginning
Git and GitHub - The beginning
 

Similar to Git within RStudio

GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
"FENG "GEORGE"" YU
 
Git/GitHub
Git/GitHubGit/GitHub
Git/GitHub
Cindy Royal
 
Git and git hub basics
Git and git hub basicsGit and git hub basics
Git and git hub basics
prostackacademy
 
Version control
Version controlVersion control
Version control
Ghufran Ataie
 
Legal Analytics Course - Class #4 - Github and RMarkdown Tutorial - Professor...
Legal Analytics Course - Class #4 - Github and RMarkdown Tutorial - Professor...Legal Analytics Course - Class #4 - Github and RMarkdown Tutorial - Professor...
Legal Analytics Course - Class #4 - Github and RMarkdown Tutorial - Professor...
Daniel Katz
 
Beginner Workshop for Student Developers - Tratech-presentation.pdf
Beginner Workshop for Student Developers - Tratech-presentation.pdfBeginner Workshop for Student Developers - Tratech-presentation.pdf
Beginner Workshop for Student Developers - Tratech-presentation.pdf
GDSCKNUST
 
Extra bit with git
Extra bit with gitExtra bit with git
Extra bit with git
gdgjss
 
Git and Github.pptx
Git and Github.pptxGit and Github.pptx
Git and Github.pptx
Hitesh670643
 
GIT By Sivakrishna
GIT By SivakrishnaGIT By Sivakrishna
GIT By Sivakrishna
Nyros Technologies
 
Hacktoberfest 2020 - Open source for beginners
Hacktoberfest 2020 - Open source for beginnersHacktoberfest 2020 - Open source for beginners
Hacktoberfest 2020 - Open source for beginners
DeepikaRana30
 
Getting started With GIT
Getting started With GITGetting started With GIT
Getting started With GIT
GhadiAlGhosh
 
Extra bit with git
Extra bit with gitExtra bit with git
Extra bit with git
Himanshu Agrawal
 
Version Control System
Version Control SystemVersion Control System
Version Control System
Md. Shafiuzzaman Hira
 
Introduction to GitHub (workshop)
Introduction to GitHub (workshop)Introduction to GitHub (workshop)
Introduction to GitHub (workshop)
Miquel Beltran Febrer
 
Contributing to github is for everyone
Contributing to github is for everyoneContributing to github is for everyone
Contributing to github is for everyone
Matt Heusser
 
Overview of github
Overview of githubOverview of github
Overview of github
Sangeetha Subramani
 
Git101
Git101Git101
Git101
Jason Noble
 
Hello, Git!
Hello, Git!Hello, Git!
1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx
HuthaifaAlmaqrami1
 

Similar to Git within RStudio (20)

GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 
Git/GitHub
Git/GitHubGit/GitHub
Git/GitHub
 
16 Git
16 Git16 Git
16 Git
 
Git and git hub basics
Git and git hub basicsGit and git hub basics
Git and git hub basics
 
Version control
Version controlVersion control
Version control
 
Legal Analytics Course - Class #4 - Github and RMarkdown Tutorial - Professor...
Legal Analytics Course - Class #4 - Github and RMarkdown Tutorial - Professor...Legal Analytics Course - Class #4 - Github and RMarkdown Tutorial - Professor...
Legal Analytics Course - Class #4 - Github and RMarkdown Tutorial - Professor...
 
Beginner Workshop for Student Developers - Tratech-presentation.pdf
Beginner Workshop for Student Developers - Tratech-presentation.pdfBeginner Workshop for Student Developers - Tratech-presentation.pdf
Beginner Workshop for Student Developers - Tratech-presentation.pdf
 
Extra bit with git
Extra bit with gitExtra bit with git
Extra bit with git
 
Git and Github.pptx
Git and Github.pptxGit and Github.pptx
Git and Github.pptx
 
GIT By Sivakrishna
GIT By SivakrishnaGIT By Sivakrishna
GIT By Sivakrishna
 
Hacktoberfest 2020 - Open source for beginners
Hacktoberfest 2020 - Open source for beginnersHacktoberfest 2020 - Open source for beginners
Hacktoberfest 2020 - Open source for beginners
 
Getting started With GIT
Getting started With GITGetting started With GIT
Getting started With GIT
 
Extra bit with git
Extra bit with gitExtra bit with git
Extra bit with git
 
Version Control System
Version Control SystemVersion Control System
Version Control System
 
Introduction to GitHub (workshop)
Introduction to GitHub (workshop)Introduction to GitHub (workshop)
Introduction to GitHub (workshop)
 
Contributing to github is for everyone
Contributing to github is for everyoneContributing to github is for everyone
Contributing to github is for everyone
 
Overview of github
Overview of githubOverview of github
Overview of github
 
Git101
Git101Git101
Git101
 
Hello, Git!
Hello, Git!Hello, Git!
Hello, Git!
 
1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx
 

Recently uploaded

原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
u86oixdj
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
vcaxypu
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
benishzehra469
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
TravisMalana
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
enxupq
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
NABLAS株式会社
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
yhkoc
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
nscud
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
ukgaet
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar
 
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdfSample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Linda486226
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
ahzuo
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Subhajit Sahu
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
Subhajit Sahu
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
nscud
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
Oppotus
 

Recently uploaded (20)

原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
原版制作(Deakin毕业证书)迪肯大学毕业证学位证一模一样
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
 
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdfSample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 

Git within RStudio

  • 1. Using Git within RStudio Paulina Jedynak, PhD github.com/paujedynak Environmental Epidemiology lab gricad-gitlab.univ-grenoble-alpes.fr 1 May 2021
  • 2. Using Git within RStudio This demo will be based on Windows OS and GitHub platform but do not worry – most of the procedures are common for different systems and platforms 2
  • 3. Using Git within RStudio After this workshop you should be able to: • Install all the necessary software to use Git version control with RStudio • Configure Git to communicate with an online repository (e.g. GitHub) • ‘Stage’, ‘commit’, ‘push’ and ‘pull’ your code to the online repository More details on each step discussed here you will find at: happygitwithr.com If you prefer less details but straight to the poing, try cfss.uchicago.edu/setup/git-with-rstudio 3 This demo will be based on Windows OS and GitHub platform but do not worry – most of the procedures are common for different systems and platforms
  • 4. 1. Initial installations Source: https://happygitwithr.com 4
  • 5. 1. Initial installations 1. Install or upgrade RStudio 5
  • 6. 1. Initial installations 1. Install or upgrade RStudio 2. Register an online account where the ‘remote’ version of your repositories will be kept. As an example I will use the GitHub platform but several other platforms exist • github.com • gitlab.com • gricad-gitlab.univ-grenoble-alpes.fr (login with AGALAN credentials) • … NOTE: Git != GitHub 6
  • 7. 7 Can be easily changed at any time
  • 8. 1. Install or upgrade RStudio 2. Register an online account where the ‘remote’ version of your repositories will be kept. As an example I will use the GitHub platform but several other platforms exist 3. Install Git software on your machine (accept the default setup options!) git-scm.com/downloads You can check if you already have Git by typing where.exe git (Windows) or which git (Mac, Linux) in the shell 1. Initial installations 8
  • 9. 1. Install or upgrade RStudio 2. Register an online account where the ‘remote’ version of your repositories will be kept. As an example I will use the GitHub platform but several other platforms exist 3. Install Git software on your machine (accept the default setup options!) git-scm.com/downloads You can check if you already have Git by typing where.exe git (Windows) or which git (Mac, Linux) in the shell 4. Open RStudio 1. Initial installations 9
  • 10. 1. Initial installations Restart/ reopen RStudio!! 10
  • 11. 1. Initial installations Make sure the RStudio “sees” Git (in Windows, after installation Git should be recognized automatically) 11
  • 12. 1. Initial installations Make sure the RStudio “sees” Git (in Windows, after installation Git should be recognized automatically) If this field is empty you need to provide the location of the git.exe file. To find it type where.exe git (Windows) or which git (Mac, Linux) in the shell
  • 13. 1. Initial installations Make sure the RStudio “sees” Git (in Windows, after installation Git should be recognized automatically) If this field is empty you need to provide the location of the git.exe file. To find it type where.exe git (Windows) or which git (Mac, Linux) in the shell Restart/ reopen RStudio!!
  • 15. 2. Introduce yourself to Git This does not have to be your GitHub user name This must be the email associated with GitHub account
  • 16. 2. Introduce yourself to Git You may check whether Git understood what you typed by using the command git config --global –list (again in the shell)
  • 17. 3. Connect to GitHub 1. Go to https://github.com and make sure you are logged in 2. Click green “New” button. Or, if you are on your own profile page, click first on “Repositories”, then click the green “New” button 17
  • 18. 3. Connect to GitHub 1. Go to https://github.com and make sure you are logged in 2. Click green “New” button. Or, if you are on your own profile page, click first on “Repositories”, then click the green “New” button 18
  • 19. 3. Connect to GitHub 1. Go to https://github.com and make sure you are logged in 2. Click green “New” button. Or, if you are on your own profile page, click first on “Repositories”, then click the green “New” button How to fill this in: 1. Repository name: e.g. test 1 19
  • 20. 3. Connect to GitHub 1. Go to https://github.com and make sure you are logged in 2. Click green “New” button. Or, if you are on your own profile page, click first on “Repositories”, then click the green “New” button How to fill this in: 1. Repository name: e.g. test 2. Description: optional but useful 1 2 20
  • 21. 3. Connect to GitHub 1. Go to https://github.com and make sure you are logged in 2. Click green “New” button. Or, if you are on your own profile page, click first on “Repositories”, then click the green “New” button How to fill this in: 1. Repository name: e.g. test 2. Description: optional but useful 3. Choose visibility: public or private* 1 2 3 *Up to 3 collaborators 21
  • 22. 3. Connect to GitHub 1. Go to https://github.com and make sure you are logged in 2. Click green “New” button. Or, if you are on your own profile page, click first on “Repositories”, then click the green “New” button How to fill this in: 1. Repository name: e.g. test 2. Description: optional but useful 3. Choose visibility: public or private* 4. Optional: add README if needed; add .gitignore file** with R template 1 2 3 4 *Up to 3 collaborators **Enables ‘hiding’ some files from being traced by Git 22
  • 23. 3. Connect to GitHub 1. Go to https://github.com and make sure you are logged in 2. Click green “New” button. Or, if you are on your own profile page, click first on “Repositories”, then click the green “New” button How to fill this in: 1. Repository name: e.g. test 2. Description: optional but useful 3. Choose visibility: public or private* 4. Optional: add README if needed; add .gitignore file** with R template 5. Click green button “Create repository” 1 2 3 4 *Up to 3 collaborators **Enables ‘hiding’ some files from being traced by Git 5 23
  • 24. 3. Connect to GitHub 24
  • 25. 3. Connect to GitHub 25
  • 26. 3. Connect to GitHub 1. Click the Code button 26
  • 27. 1. Click the Code button 2. Copy the link from the HTTPS tab to your Clipboard 27
  • 28. 1. Click the Code button 2. Copy the link from the HTTPS tab to your Clipboard 28 IF YOU CANNOT FIND THE ‘CODE’ BUTTON, DON’T PANIC! It means you created an empty repository (without README, .gitignore or any other file). As soon you add a file to the repo (e.g. README), the button will appear
  • 29. 4. Clone the repo to your local machine Now you have 2 options depending if you are starting a new R Project or you already have an existing R Project that you want to connect with Git 29
  • 30. 4. Clone the repo to your local machine Brand new R Project: 1. In RStudio >> File >> New Project… 2. Choose Version Control 3. Choose Git 4. Paste the link to your repository into the Repository URL field (the Project directory name will be filled automatically) 5. Click Browse… to choose the location where your new Project will be created 6. Click Create Project 30
  • 31. 4. Clone the repo to your local machine 31 Brand new R Project: 1. In RStudio >> File >> New Project… 2. Choose Version Control 3. Choose Git 4. Paste the link to your repository into the Repository URL field (the Project directory name will be filled automatically) 5. Click Browse… to choose the location where your new Project will be created 6. Click Create Project
  • 32. 4. Clone the repo to your local machine You can commit, push and pull… 32 Brand new R Project: 1. In RStudio >> File >> New Project… 2. Choose Version Control 3. Choose Git 4. Paste the link to your repository into the Repository URL field (the Project directory name will be filled automatically) 5. Click Browse… to choose the location where your new Project will be created 6. Click Create Project
  • 33. 5. Connect Git to an existing R project Existing R Project: 1. Open an existing Project 33
  • 34. Existing R Project: 1. Open an existing Project 2. Tools >> Version Control >> Project Setup… 3. Choose Git as Version control system 4. Accept the following prompts 5. Connect Git to an existing R project 34
  • 35. At this stage your version control works only locally (it is not connected with an online repository) – you may want to keep it like this or you may want to link it to the remote repository 5. Connect Git to an existing R project 35 Existing R Project: 1. Open an existing Project 2. Tools >> Version Control >> Project Setup… 3. Choose Git as Version control system 4. Accept the following prompts
  • 36. Connect to an online repository: 1. Create a remote repository as explained earlier in this presentation (3. Connect to GitHub). IMPORTANT: repo name must match your existing Project name 2. Copy the repo link to your Clipboard 5. Connect Git to an existing R project 36
  • 37. Connect to an online repository: 1. Create a remote repository as explained earlier in this presentation (3. Connect to GitHub). IMPORTANT: repo name must match your existing Project name 2. Copy the repo link to your Clipboard 3. Add remote URL to your existing Project using shell by typing: 4. Check the remote URL using shell by typing: 5. Connect Git to an existing R project 37 git remote add origin https://github.com/username/reponame.git where username is your GitHub username and reponame is your GitHub repository name git remote -v
  • 38. Connect to an online repository: 1. Create a remote repository as explained earlier in this presentation (3. Connect to GitHub). IMPORTANT: repo name must match your existing Project name 2. Copy the repo link to your Clipboard 3. Add remote URL to your existing Project using shell by typing: 4. Check the remote URL using shell by typing: 5. Connect Git to an existing R project 38 git remote -v
  • 39. Connect to an online repository: 1. Create a remote repository as explained earlier in this presentation (3. Connect to GitHub). IMPORTANT: repo name must match your existing Project name 2. Copy the repo link to your Clipboard 3. Add remote URL to your existing Project using shell by typing: 4. Check the remote URL using shell by typing: 5. Connect Git to an existing R project 39 git remote -v IF THIS FIELD IS EMPTY OR ‘PUSH’ AND ‘PULL’ BUTTONS ARE GREYED OUT (INACTIVE), DON’T PANIC! Restart / reopen RStudio. If the problem persists, make some commit and make a push setting the upstream by typing in the shell: git push origin master -u
  • 40. Connect to an online repository: 1. Create a remote repository as explained earlier in this presentation (3. Connect to GitHub). IMPORTANT: repo name must match your existing Project name 2. Copy the repo link to your Clipboard 3. Add remote URL to your existing Project using shell by typing: 4. Check the remote URL using shell by typing: 5. Connect Git to an existing R project 40 git remote -v You can commit, push and pull…
  • 41. 41 6. Commit, push and pull MAKE A COMMIT every time you finish a valuable chunk of work, probably many times a day
  • 42. 42 6. Commit, push and pull • All files within the Project are ‘observed’ by Git, unless added to the .gitignore file • If there are any changes in the Project – new files created (new_script.R), any SAVED changes made to the content of existing files (README.md) etc., Git will keep notifying you and will let you decide if to start tracking them (new files) or commit changes (modified files)
  • 43. 43 6. Stage, commit, push and pull Git informes you that new files appeared in the Project (? ? = ‘unknown’ status) CREATING NEW FILES, MODYFYING EXISTING ONES
  • 44. 44 6. Stage, commit, push and pull Git informes you that new files appeared in the Project (? ? = ‘unknown’ status) Git informes you that changes were made to a file (M = ‘modified’ status) CREATING NEW FILES, MODYFYING EXISTING ONES
  • 45. 45 6. Stage, commit, push and pull Git informes you that new files appeared in the Project (? ? = ‘unknown’ status) Git informes you that changes were made to a file (M = ‘modified’ status) • By ticking files you stage them (it is a necessary step before a commit) so you let Git know which files will be included in your next commit • By staging a new file (new_script.R) you let Git know you want it to start tracking this file (A = ‘adding for tracking’ status) • By staging a modified file (README.md) you let Git know you want to capture the file content modification STAGING CREATING NEW FILES, MODYFYING EXISTING ONES
  • 46. 46 6. Stage, commit, push and pull Git informes you that new files appeared in the Project (? ? = ‘unknown’ status) Git informes you that changes were made to a file (M = ‘modified’ status) • By ticking files you stage them (it is a necessary step before a commit) so you let Git know which files will be included in your next commit • By staging a new file (new_script.R) you let Git know you want it to start tracking this file (A = ‘adding for tracking’ status) • By staging a modified file (README.md) you let Git know you want to capture the file content modification • After you staged all the files, click ‘Commit’ button STAGING CREATING NEW FILES, MODYFYING EXISTING ONES
  • 47. 47 6. Stage, commit, push and pull COMMIT • A new window pops-out where you need to provide an informative description of the commit (Commit message) so in the future you can easily find the commit by name • No need to include date in the commit, it is automatically dated
  • 48. 48 6. Stage, commit, push and pull COMMIT • A new window pops-out where you need to provide an informative description of the commit (Commit message) so in the future you can easily find the commit by name • No need to include date in the commit, it is automatically dated • Clicking on a staged file (README.md) we can see the changes (‘diff’) made in the file (deleted lines in red, modified/new lines in green) • Clicking ‘Commit’ button captures an image of the code in a particular time point
  • 49. 49 6. Stage, commit, push and pull COMMIT • A new window pops-out where you need to provide an informative description of the commit (Commit message) so in the future you can easily find the commit by name • No need to include date in the commit, it is automatically dated • Clicking on a staged file (README.md) we can see the changes (‘diff’) made in the file (deleted lines in red, modified/new lines in green) • Clicking ‘Commit’ button captures an image of the code in a particular time point
  • 50. 50 6. Stage, commit, push and pull PUSH • After the commit, the staged files disappear
  • 51. 51 6. Stage, commit, push and pull PUSH • After the commit, the staged files disappear • You are also informed that your local repository is ahead of the remote one by one commit (your local version is newer than the online one by one commit) • You do not need to push each time you make a commit, you can do it e.g. at the end of the day
  • 52. 52 6. Stage, commit, push and pull PUSH • After the commit, the staged files disappear • You are also informed that your local repository is ahead of the remote one by one commit (your local version is newer than the online one by one commit) • You do not need to push each time you make a commit, you can do it e.g. at the end of the day • To push your code to the online repository, click on the green ‘Push’ button
  • 53. 53 6. Stage, commit, push and pull PULL • If you want to e.g. synchronize your work between machines (e.g. your computer at work and another one at home; your machine and your colleague’s machine who works with you on a project, etc.), on the machine where the work is outdated, click the blue ‘Pull’ button • Pulling will ‘download’ new versions of your tracked files and replace/ merge with the old ones
  • 54. 54 6. Stage, commit, push and pull PULL • If you want to e.g. synchronize your work between machines (e.g. your computer at work and another one at home; your machine and your colleague’s machine who works with you on a project, etc.), on the machine where the work is outdated, click the blue ‘Pull’ button • Pulling will ‘download’ new versions of your tracked files and replace/ merge with the old ones • Do not worry (too much) about overwriting some important files – Git will inform you if there are any conflicts • If you work on several machines and do Push and Pull frequently, get used to starting your work by making a Pull (you will avoid conflicts)
  • 55. 55 6. Stage, commit, push and pull
  • 56. 56 6. Stage, commit, push and pull History
  • 57. 57 7. Reversing a commit (or peeking to the history)
  • 58. 58 *revert != reset != checkout… (the most confusing part of Git) The need to revert the changes in the code in a particular way will be specific for the working environment (e.g., if you need to get the last working version in the matter of hours/minutes – common in big scale production setups; if you work alone or with several developers of the same code, etc.) 7. Reversing* a commit (or peeking to the history) Undoing things: basic level git-scm.com/book/en/v2/Git-Basics-Undoing-Things Undoing things: level pro git-scm.com/book/en/v2/Git-Tools-Reset-Demystified
  • 59. 59 The most common scenarios when I go back in time: 1. Reversing the code to its version in the particular point in the past Happens very rarely (once per project and rather towards its end, when the code is close to its final version) 2. Peeking in previous versions of the code to retrieve specific function or chunk of code Happens frequently (several times per project, at any development stage) 7. Reversing a commit (or peeking to the history)
  • 60. 60 The most common scenarios when I go back in time: 2. Peeking in previous versions of the code to retrieve specific function or chunk of code Happens frequently (several times per project, at any development stage) –> GoogleDocs version history 7. Reversing a commit (or peeking to the history)
  • 61. 61 The most common scenarios when I go back in time: 7. Reversing a commit (or peeking to the history) You may restore the old version of the script, in the same form as it was in the past (.R, .Rmd, .html…) and copy paste the chunk of code or save the entire script (but if you want to save the old file and use it to replace the never files – do not go there, reversing a commit is the tool you need!)
  • 62. 62 Summary • Git is a great tool if you want to share work within projects (e.g. several persons committing to the same project – NO MORE SENDING CODE BY EMAIL!!!) • Different collaborators (or your different machines) have the same version of the code plus they have access to all the changes made by any user (or by you in different time points) • Ideally, when using Git, you should be consequent: make frequent commits that are named in an informative way and contain logically linked chunks of work. At the beginning it may not be easy, but it pays off • Using Git allows you to reverse an error/ retrieve deleted files or chunks of code relatively easily (the more disciplined you are, the easier it becomes) • The longer you work with Git, the less often you discover that all the files disappeared from your workspace and you have no idea where they went. At the end, in the 90% of cases they reappear 
  • 63. Thank you for your attention Paulina Jedynak, PhD github.com/paujedynak paulina.jedynak@gmail.com Environmental Epidemiology lab gricad-gitlab.univ-grenoble-alpes.fr 63

Editor's Notes

  1. Git is an installable and executable software (like an R or RStudio) while GitHub is a website, an online repository, where information (e.g. code) can be stored. Git (software) can communicate with different online repositories (e.g. GitHub or GitLab) but these are independent tools.
  2. Git is an installable and executable software (like an R or RStudio) while GitHub is a website, an online repository, where information (e.g. code) can be stored. Git (software) can communicate with different online repositories (e.g. GitHub or GitLab) but these are independent tools.
  3. Git is an installable and executable software (like an R or RStudio) while GitHub is a website, an online repository, where information (e.g. code) can be stored. Git (software) can communicate with different online repositories (e.g. GitHub or GitLab) but these are independent tools.
  4. Git is an installable and executable software (like an R or RStudio) while GitHub is a website, an online repository, where information (e.g. code) can be stored. Git (software) can communicate with different online repositories (e.g. GitHub or GitLab) but these are independent tools.
  5. Git is an installable and executable software (like an R or RStudio) while GitHub is a website, an online repository, where information (e.g. code) can be stored. Git (software) can communicate with different online repositories (e.g. GitHub or GitLab) but these are independent tools.
  6. This command may be useful if Git is installed but RStudio cannot find it (especially for other than Windows users).
  7. This command may be useful if Git is installed but RStudio cannot find it (especially for other than Windows users).
  8. This command may be useful if Git is installed but RStudio cannot find it (especially for other than Windows users).
  9. This command may be useful if Git is installed but RStudio cannot find it (especially for other than Windows users).