The first time you pull/push

You get an error about

unable to read askpass response from 'rpostback-askpass' ... Device not configured

In the git tab, click more and then Shell. At the command line that opens type: git push

Enter your github username and password when it requests them. If it works with no errors, return to RStudio, create a test file, commit it and push to check things are working.

When you push you get the error

To https://github.com/gitelman/BigData.git
! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/gitelman/BigData.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

git is complaining there a new commits to the repo you don’t have. If you are lucky, you won’t have changed anything anyone else has, and git can merge automatically. Try it, pull, if it works, great! Then try pushing.

If you get the error

From https://github.com/gitelman/BigData
091a512..8439e38  master     -> origin/master
Auto-merging Project1/conflict-test.txt
CONFLICT (content): Merge conflict in Project1/conflict-test.txt
Automatic merge failed; fix conflicts and then commit the result.

The new commits on the repo conflict with your local commits. RStudio should pop open the offending file, and also mark it with a u in the git tab. Inside the file look for the <<<<<<< and choose which edit to keep by deleting the other edits and all the << and ==. Save the file, in the git tab the file should change from an icon of u to m, if it doesn’t check the stage box and it should, commit it and push/pull.

This won’t work for binary files (Word docs, Powerpoint, .rda or .rds files), in that case open up the shell from RStudio (git tab -> More -> Shell), then run one of the following:

git checkout --theirs path/to/conflicted-file.txt
git checkout --ours path/to/conflicted-file.txt

Use theirs to keep the version on the repo, ours to keep your version. Then back in RStudio, stage the file and commit.

Some other hints

If you get into trouble you can always open the Shell, and type git status, it tells you what’s going on, and often what you need to do to get out of trouble.

If you are worried about a commmand deleting all your local work, open the Shell and type git stash, that will store everything as is, and after you run the command you can do git stash apply to get your local files back.

If you delete the folder locally you will lose any local only changes (and commits).