These guidelines explain the different steps to be taken when collaborating in a Github repository while developing code in RStudio. The main aim is to give a concise overview rather than giving detailed information on different options or showing screenshots for each step. The steps presented here follow more or less this schedule but the explanations and tips are rather complementary.
Ask for changes or propose to make changes in a Github repository:
Issues
New issue
Issues can be used to:
Issues can be:
(If you don’t have the project locally, check the manual here.)
In RStudio on the Git
tab:
main
branch is active and up to date (Pull
)New Branch
(hit button) and give it an informative nameCommit
for every change
Push
your changes to the repository on github (at least once a day, not too frequently as every push might trigger automated tests)These steps are described into detail in a separate workflow and in this manual.
Create a pull request when your work is ready to share with collaborators.
In RStudio, make sure all changes are committed and pushed.
In the GitHub repository:
Compare & pull request
button that appears after recent pushesNew pull request
buttonCreate Pull request
For an explanation including screenshots, see here or here.
Remark: after creating a pull request, it is still possible to add new commits to this branch and pull request. After pushing new commits in RStudio, they appear in the pull request. To show others that you are not finished yet, you can convert the pull request to draft (right top of page, where you request reviewers)
Reviewers will receive an email with a link to the pull request, and they can:
Conversation
, Commits
and Files changed
Pull
and select the branch name (mentioned at the top of the pull request in GitHub)During this revision, in the Pull request on GitHub:
Commit suggestions
(easiest in files change
tab)Conversation
tab)Once you and your coworkers agreed on the final version in your branch, it can be merged to the main branch:
Pull
More
and choose Shell...
git merge main
(or replace main by the name of the branch you want to merge to your branch)code
<<<<<<< HEAD
code in your active branch
=======
code in the main branch
>>>>>>> main
more code
Push
all new commits to GitHubMerge pull request
Confirm merge
Delete branch
to keep your repo clean and clearFor screenshots, see here.
When merging to the main branch or another important branch in the repo, always do this on GitHub by using a pull request. It is recommended to protect these branches to enforce this procedure.
Once you are satisfied with a version, you can create a release.
After deleting branches on the remote, you may want to get rid of them as well in the selection list in the git pane in RStudio. It is done automatically after following these configuration steps once. But it can also be done manually:
More
on the Git
tab and choose Shell...
git fetch -p
to remove branches that don’t exist anymore on the origingit branch -d <branch name>
to remove local branch <branch name>
(branches that are merged can be listed with git branch --merged
)