Create a new repository on GitHub and link to RStudio project
Now you may want to push the contents of this commit to GitHub, so it is also backed-up off site and available to collaborators.
As always, you must exercise caution when working with sensitive data.
Take steps to stop yourself from accidentally pushing whole datasets to GitHub.
You only want to push R code to GitHub, not the (sensitive) data.
When you see a dataset appear in the Git tab of your RStudio, select it, then click on More, and then Ignore.
This means the file does not get included in your Git repository, and it does not get pushed to GitHub.
GitHub is not for backing up sensitive datasets, it’s for backing up R code.
And make sure your R code does not include passwords or access tokens.
In GitHub, create a New repository, called here myproject (Figure 14.4A).
You will now see the Quick setup page on GitHub.
Copy the code below push an existing repository from the command line (Figure 14.4B).
FIGURE 14.4: Create a new repository (repo) on GitHub.
Back in RStudio, paste the code into the Terminal.
Add your GitHub username and password (important!) (Figure 14.5A).
You have now pushed your commit to GitHub, and should be able to see your files in your GitHub account.
The Pull and Push buttons in RStudio will now also work (Figure 14.5B).
To avoid always having to enter your password, copy the SSH address from GitHub and enter the code shown in Figure 14.5C and D.
Check that the Pull and Push buttons work as expected (Figure 14.5E).
Remember, after each Commit, you have to Push to GitHub, this doesn’t happen automatically.
FIGURE 14.5: Linking an RStudio project with a GitHub repository.