What can I learn from RStudio git commands?

I'm trying to increase my comfort with using git in the terminal; currently I do whatever I can through the RStudio interface. I'm curious about a few things:

  • Is trying to learn git from automated RStudio commands the wrong approach altogether? (Perhaps, for example, RStudio is set up to cover more cases than I need to concern myself with since I know the specifics of my project.)

  • If not -- i.e. knowing what RStudio is doing is a useful exercise -- is it possible to see what git commands RStudio executes? (Sometimes I see them but other times they scroll by too quickly for example when creating a new project with version control from an existing GitHub repository.)

  • More specifically, the standard RStudio version of git pull and git push seem to be:

>>> git pull --rebase

>>> git push origin refs/heads/master

Why --rebase? Why refs/heads/master?

(I may very well be barking up the wrong tree here; if so, let me know!)

2 Likes

By default, when running git pull, Git will perform a merge for you if your local copy is out-of-sync with the remote. We find that a rebase is often preferred to a merge in this context: that is, one typically wants to pull the latest changes from the remote, and then overlay any local changes on top of what's happened on your remote.

Some more justification is here: https://stackoverflow.com/questions/2472254/when-should-i-use-git-pull-rebase

As for git push origin refs/heads/master, I don't have a good answer :slight_smile: It would probably be sufficient for us to just invoke git push origin master.

2 Likes

Really helpful, thanks! I guess I'm over my fear of rebasing, having unwittingly done it many, many times!

Actually, I see now that you have a choice: you can either click the pull button or the tiny down arrow on the right which brings up the Pull with Rebase option.