Revision Control - Locally Save Changes

As you edit the code you should regularly save ("check in", "commit") your changes in Git. This way if you make a mistake, you can always back up to a prior version. I'll often save my changes to Git about once a hour when I'm doing a lot of development.

First make sure all your changes are saved in RStudio.

With RStudio

  1. Goto the Git tab. You should see the modified files listed in the panel
    • Files marked with M are modified
    • Files marked with ? are new files
  2. Check the staged box next to the files you want to save a version of in Git at this time
  3. Click "Commit". The commit screen will pop-up.
  4. In the upper right type a log message for what you changed in the files
  5. Click "Commit" to save the version of the checked files

The files now have a version locally saved. They have not been saved on the server.

From the Command Line

  1. Check the status of files
    % git status -s
    • Files marked ?? are not being tracked by Git and a copy won't be saved
    • Files marked A or M are being tracked and a copy will be saved
  2. If there is a file that is not being tracked and you want a copy saved by Git, add the file
    % git add <filename>
  3. Locally save a copy ("check in", "commit") of all the changed, tracked local files
    % git commit -a -m "updated code to do X"
    • If you don't use a -m command a editor will be brought up to type a message into. Which editor depends on your system and how you've configured it.