1. Prerequisites (chapter 12)
- Registered a free GitHub account (chapter 4).
- Installed/updated R and RStudio (chapter 5).
- Installed Git (chapter 6).
- Introduced yourself to Git (chapter 7).
- Confirmed that you can push to / pull from GitHub from the command line (chapter 9).
2. Make a repo on GitHub
Go to https://github.com and make sure you are logged in.
On your own profile page, click on “Repositories”, then click the green “New” button.
Then to fill like this:
- Repository name: myrepo (or whatever you wish, we’ll delete this soon anyway).
- Description: “testing my setup” (or whatever, but some text is good for the README).
- Public.
- Initialize this repository with a README.
For everything else, just accept the default.
Click big green button “Create repository.”
Click the green “Code” button, then copy the HTTPS clone URL to your clipboard
3. Clone the repo to your local computer
In RStudio, start a new Project:
File > New Project > Version Control > Git. In “Repository URL”, paste the URL of your new GitHub repository. It will be something like this https://github.com/Kaining26/myrepo.git. Accept the default project directory name, e.g. myrepo, which coincides with the GitHub repo name.
Take charge of where the Project will be saved locally. A commonmistake is to have no idea where you are saving files or what your working directory is.
Check “Open in new session”.
Click “Create Project”. You should find yourself in a new local RStudio Project that represents the new test repo we just created on GitHub.
4. Push your local changes online to GitHub
Go to the shell. In RStudio, Tools > Shell
Type these command lines one by one:
- git add -A
- git commit -m “A commit from my local computer”
- git push
Note: Every time you make a commit you must also write a short commit message. Ideally, this conveys the motivation for the change.
5. Confirm the local change propagated to the GitHub remote
Go back to the browser. Reload the Github webpage.You should see all your local files of this project being uploaded to the repo.
6. How if changes are made from Github and you want to sync in your local computer (chapter 15)
Assume you add “Line added from GitHub” in Github and commit changes.
Back to local RStudio. Inspect your README.md. It should NOT have the line “Line added from GitHub”.
Click the Pull button at the upper right panel.
Look at README.md again. You should now see the new line there.
7. View HTML file published on Github online (chapter 33)
To preview HTML files on GitHub is to go to https://htmlpreview.github.io/ or just prepend it to the original URL, i.e.: https://htmlpreview.github.io/?https://github.com/Kaining26/practice/blob/main/2ndrmd.html