15 RStudio, Git, GitHub Hell

Problems we have seen and possible solutions.

If you experience some new problem and, especially, find the corresponding solution, we’d love to hear from you!

15.1 I think I have installed Git but damn if I can find it

When you install Git, try to control or record where it is being installed! Make a mental or physical note of these things.

You may be able to find Git after the fact with these commands in the shell:

  • which git (Mac, Linux, or anything running a bash shell)

  • where git (Windows, when not in a bash shell)

It is not entirely crazy to just re-install Git, using a method that leaves it in a more conventional location, and to pay very close attention to where it’s being installed. Live and learn.

15.2 RStudio Git pane disappears on Mac OS

After a Mac OS upgrade, you might need to trigger the Xcode command line tools to prompt you for what it needs, i.e. to re-install or re-agree to the license agreement. We have seen this cause the RStudio Git pane to disappear on a system where it was previously working. Use commands like these below to tickle Xcode:

xcode-select --install


git config --global --list

Then restart RStudio.

15.3 Dysfunctional PATH

I’m pretty sure that most cases of RStudio not automatically detecting the Git executable stem from problems with PATH. This is the set of directories where your computer will look for executables, such as Git (today) or make (later in this course). Certain methods of Git installation, especially on Windows and/or older OSes, have a higher tendency to put Git in an unconventional location or to fail to add the relevant directory to PATH.

How to see your PATH?

In the shell:

echo $PATH

Take a good hard look at this. See the point above about finding your Git executable or re-installing it while you are wide awake. Is the host directory in your PATH? No? Fix that.

Go here for instructions on what to put in your .bash_profile in order to add a directory to PATH.

15.4 Push/Pull buttons greyed out in RStudio

Are you sure your local repository is associated with a remote repository, e.g. a GitHub repo? In a shell with working directory set to the local Git repo, enter this command:

jenny@2015-mbp myrepo $ git remote -v
origin  https://github.com/jennybc/myrepo (fetch)
origin  https://github.com/jennybc/myrepo (push)

We want to see that fetch and push are set to remote URLs that point to the remote repo. Note also that the GitHub repo is a remote named origin, as far as your local repo is concerned. This is typical and, though I think github is a vastly superior name, origin is such a strong convention that I follow it.

If you discover you still need to set a remote, get the HTTPS or SSH URL, as appropriate, for your GitHub repo. This is easy to get onto your clipboard from the repo’s GitHub page. Do this in the shell:

git remote add origin https://github.com/jennybc/myrepo.git

Download all the files from the online GitHub repository and deal with any conflicts.

git pull origin master

Call git remote -v again. Once you can prove that your GitHub remote is set properly, you can move on to the next step.

Are you sure the current branch is tracking a branch on the remote? In that same shell, in your repo, do this:

jenny@2015-mbp myrepo $ git branch -vv
* master b8e03e3 [origin/master] line added locally

The above shows successful confirmation that the local master branch is tracking origin/master, i.e. the master branch on GitHub. If you don’t see the [origin/master] bit, that is a problem. By the way, git branch -r is another handy way to examine your remote-tracking branches. (If you’re working with a branch other than master, adjust everything accordingly.)

When connecting a local repo to a new GitHub repo, a lot of people remember to add the GitHub remote, but forget to also cement this tracking relationship for any relevant branches.

If you discover your local master branch is not yet tracking master on GitHub, fix that like so:

git push --set-upstream origin master

This is equivalent to git push -u origin master but conveys more about what you are doing.

Call git branch -vv or git branch -r again to confirm that the master branch on GitHub is the upstream or tracking branch for the local master branch.

15.5 I have no idea if my local repo and my remote repo are connected.

See the above section on “Push/Pull buttons greyed out in RStudio.”

15.6 Push fail at the RStudio level

Do you get this error in RStudio?

error: unable to read askpass response from 'rpostback-askpass'

Open the shell: Tools > Shell.

git push -u origin master

15.7 Push rejected, i.e. fail at the Git/GitHub level

You might have changes on the remote AND on your local repo. Just because you don’t remember making any edits in the browser doesn’t mean you didn’t. Humor me.

Pull first. Resolve any conflicts. Then try your push again.

15.8 RStudio is not making certain files available for staging/committing

Do you have a space in your directory or file names? A space in a file name is a space in your soul. Get rid of it.

Is your Git repo / RStudio Project inside a folder that … eventually rolls up to Google Drive, DropBox, Microsoft OneDrive, or a network drive? If yes, I recommend you move the repo / Project into a plain old directory that lives directly on your computer and that is not managed by, e.g., Google Drive.

If you cannot deal with the two root causes identified above, then it is possible that a more powerful Git client (chapter 9) will be able to cope with these situations. But I make no promises. You should also try Git operations from the command line.

15.9 I hear you have some Git repo inside your Git repo

Do not create a Git repository inside another Git repository. Just don’t.

If you have a genuine need for this, which is really rare, the proper way to do it is via submodules.

In STAT 545, we certainly do not need to do this and when we’ve seen it, it’s been a mistake. This has resulted in the unexpected and complete loss of the inner Git repository. To be sure, there was more going on here (cough, GitHub Desktop client), but non-standard usage of Git repos makes it much easier to make costly mistakes.