Working with the website
This guide will walk you through the process of contributing to a Hugo website using Git, tailored for those familiar with R. We’ll cover forking, cloning, adding, committing, pushing, and creating a Pull Request (PR).
Understanding Forking and Cloning
-
Forking: Think of forking as creating your own personal copy of the website’s code repository on a platform like GitHub. It allows you to make changes without directly affecting the original repository.
-
Cloning: Once you have your forked copy online, cloning downloads it to your local computer so you can work on the files.
Step-by-Step Guide
{usethis} has several handy functions for working with git repositories. This forks and clones the repo, so you will end up having a version of the R-Ladies website in your GitHub, and a local copy of it to work on.
install.packages("usethis")
usethis::create_from_github("rladies/rladies.github.io")
If you prefer doing things yourself.
Step 1: Fork the Repository
- Go to the repository page (e.g.,
https://github.com/rladies/rladies.github.io
). - Click the “Fork” button (usually in the top right).
- Choose your personal account to fork to.
You now have a copy like your_username/rladies.github.io
.
Step 2: Clone Your Fork
Using the Terminal:
- Open your terminal.
- Navigate to your desired directory:
cd ~/Documents/Projects
- Copy the HTTPS URL of your fork (
https://github.com/your_username/rladies.github.io.git
). - Clone the repository:
git clone https://github.com/your_username/rladies.github.io.git
- Navigate into the cloned directory:
cd rladies.github.io
Step 3: Create a New Branch
Using the Terminal:
- Switch to the main branch:
git checkout main
- Create and switch to a new branch:
git checkout -b your-new-branch-name
Using usethis
in R:
- Create and switch to a new branch:
usethis::pr_init("your-new-branch-name")
Step 5: Make Your Changes
Edit the Hugo markdown files using your preferred editor.
Step 6: Add Your Changes
Using the Terminal:
git status
git add path/to/your/file.md
git commit -m "Your descriptive commit message"
Using RStudio:
Look in the git pane, and add and commit the files you have been working on.
Step 8: Push Your Changes to Your Fork
Using the Terminal:
- Push your branch:
git push origin your-new-branch-name
Using usethis
in R:
- Push your branch:
usethis::pr_push()
Step 9: Create a Pull Request (PR)
- Go to your forked repository on GitHub.
- Click “Compare & pull request” or “Contribute”.
- Specify the Base Branch: Choose the correct branch in the original repository (e.g.,
main
,develop
,deepl
). - Review your changes.
- Add a title and description to your PR.
- Click “Create pull request”.
Step 10: Keep Your Fork in Sync
Using the Terminal:
- Switch to
main
:git checkout main
- Fetch upstream changes:
git fetch upstream
- Merge upstream
main
:git merge upstream/main
- Push to your fork:
git push origin main
Using usethis
in R:
- Pull upstream:
usethis::pr_pull()
- Push to your fork:
usethis::pr_push()