Working with git

Published

June 3, 2024

When you have closed RStudio after your work, it’s time to push your changes to GitHub using git, so that your collaborators can see and use what you have been working on.

In the terminal, add any new files using git add ., the . here can be interpreted as “everything”. Next, it is time to give our changes a message, git commit -m "Added new analyses". Lastly, we push it to Github git push.

Adding changes with git

This is a diagram depicting a typical workflow with git. Typically, you would start your day at 1 and finish at 6.

CircularProcess Git workflow A 1 Pull latest changes git pull B 2 Update any new dependencies renv::restore() A->B open project_name.RProj C 3 Register any new packages renv::snapshot() B->C Do your work D 4 Add any untracked files git add . C->D Close RStudio and go back to terminal E 5 Commit your changes git commit -m "Adds new analyses" D->E F 6 Push your changes to GitHub git push E->F F->A Start over