4.9 How to stage, commit, and push to Github using RStudio Server

4.9.1 Step - 1

Click on the “Git” which is present in the upper right window. After clicking the Git button, you will see a list of all files that have been changed since the last commit.

4.9.2 Step - 2

Click on the “Staged” checkbox to stage files which you want to push to GitHub and click on the “Commit”.

4.9.3 Step - 3

A new window will open, and it will reflect you the files which you want to commit to GitHub repository. You can also write a commit message in the “Commit message” textbox and then click the “Commit” button. (DO NOT check the box which says “Amend previous commit” - this will only lead to disaster).

You will see the following screen after clicking on the “Commit” button. Close the window by clicking the “Close” button.

4.9.4 Step - 4

After committing the files on GitHub, you will find the upper right window empty. It means that you have committed the files to the repository. Now, in the final step, you need to click on “Push” to push the files in the repository.

4.9.5 Step - 5

If you have correctly set-up a GitHub PAT (instructions here), then the Push should run normally.

If there is a problem, one of these things may have happened:

  • If RStudio asks you for a GitHub username or password, or if you get an error about authentication (e.g. “Support for password authentication was removed…”) then you have probably not followed all of those set-up steps correctly to create a Personal Access Token for GitHub and store it in RStudio: https://book.cds101.com/initial-set-up.html

  • If you get an error about “merge conflicts” then you have somehow ended up with conflicting versions of the file in RStudio and on GitHub (this can happen if you manually uploaded a file to GitHub, or if you opened the project in multiple sessions of RStudio simultaneously). If you are not sure how to fix these merge conflicts, then you should contact an instructor for help.

  • If you get an error about “unrelated histories”, then you accidentally checked the “Ammend previous commit” box in Step 3 above. You will need to create a new version of the project in GitHub and

In the end, you will see a new window containing Git Push message. If everything is correct, then there will not be any errors, and your files have been successfully pushed in GitHub repository.

4.9.6 Step - 6

You can also crosscheck on GitHub by accessing the specific repository.

In this way, you can easily stage, commit and push to GitHub using RStudio Server. If you have any questions or concerns, then please contact your advisor.