1

I am having some sort of communication issue with my RStudio project and GitHub, potentially related to updating R and RStudio.

I recently updated my R to version 4.0.3 on my windows machine:

R version 4.0.3 (2020-10-10); Platform: x86_64-w64-mingw32/x64 (64-bit)

I also updated my RStudio to Version 1.3.1093, and finally, as a result of the issues below, I updated my git version to 2.30.0.windows.1

I have two existing R Packages hosted on GitHub, and recently created a third. To create my new Repo and link it to my local project I followed the instructions on: https://aberdeenstudygroup.github.io/studyGroup/lessons/SG-T1-GitHubVersionControl/VersionControl/

I have interacted with GitHub to update my current packages, but it's been years since I created a new repository. It wasn't easy but eventually everything seemed to be working properly. I made some edits, performed a commit, went to push (using the shell or RStudio's GUI) and got this error:

To github.com:user/repo.git
 ! [rejected]        HEAD -> main (non-fast-forward)
error: failed to push some refs to 'github.com:user/repo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I am the only person using this repo, and when I perform a pull, I'm told everything is up to date. I also found a post suggesting I first fetch, then rebase (Git push rejected "non-fast-forward"). When I tried these steps I got an error:

$ git rebase tmp
error: could not apply 4fc4d3e... Conflict test
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 4fc4d3e... Conflict test
CONFLICT (add/add): Merge conflict in R/conflict test.R
Auto-merging R/conflict test.R

How do I have a conflict? How can my local copy be behind if I am the only one working on this project?

To work around this I've started performing commits, then forcing the push via git push -f origin main. Since I am the only person who will ever work on this project, perhaps this is safe; however, it's obviously not recommended and shouldn't be needed.

Also, I went back to my previous packages and performed some test commits. Sure enough, I now have this same error when I try to push new commits to GitHub for packages that were communicating perfectly previously.

I have spent some time trying to figure this out, but my efforts are limited to trying to create the repo and local package in different ways and connecting them with SSH vs URL, etc. I'm not well versed in GitHub; once my previous projects were set up I just used the same protocol to commit and push (again, I am the only user editing any of these packages). My guess is that somehow my updates to R, RStudio, or git seem to have created some sort of communication issue that I can't figure out.

  • 1
    Compare your local `git log` to the history of commits on the github site. Or you can compare `git log` to `git log origin/master` (assuming default naming conventions). Do the commit IDs match? It seems very unlikely an update to R or RStudio would impact your git repo. Have you looked into what exactly the conflicts are in those files? It's going to be very difficult to offer specific advice without more details. – MrFlick Jan 05 '21 at 20:20
  • They appear to match. For testing, I created a test repo and RStudio package. In my project I have one .R file, with the word "test" in it (in order to get this to the remote I had to force push). If I change anything in that file (e.g., make the text "test again"), commit it, and try to push it, I get the same error. If I overcome this error and manage to get everything up to date, my next commit and subsequent push brings the error right back. – Annika Elsie Jan 05 '21 at 21:41
  • Are you only working on one computer? For this test you created a new repo? And you still had to force push to github? Did you create the repo first on github and then clonse it, or did you create locally and then push it? Are you rebasing locally? Does this happen if you leave RStudio out of it? That is, can you just create a repo with just a text file in it? It would be helpful to update your question with the minimal number of steps to exactly replicate the problem so we can run and test it ourselves. – MrFlick Jan 05 '21 at 21:53
  • Thanks for the prompts. In response to your comment, I created a new repo with a text file using git bash (git init, git add, git commit). Then I created a repo on github and used git remote add origin, renamed master to main since my computer defaults to master, and pushed. Worked. I then associated a new RProj with the repo and added a file, which also worked. But when I copied over my desc, namespace, R and man files from my package I got the error. I deleted them and tried adding them slowly. Sometimes I get an error sometimes not. Pausing between commit and push doesn't make a difference. – Annika Elsie Jan 06 '21 at 02:37
  • I'm afraid that doesn't really offer a lot of new information. It seems very unlikely that git problems would just "sometimes" occur. There's nothing really stochastic about those operations. Do you have any github actions set up on your account that are modifying the files after upload? – MrFlick Jan 06 '21 at 02:48
  • Ok thanks, starting to lose hope but I'm learning a lot about git and the terminal! I don't know enough about github to have actions. I played around a bit more with pushing and pulling. It seems that after the error, if I pull I get "Already up to date" and "Merge made by recursive strategy". Then I am able to push. After getting the error I tried git diff main origin/main, but the only difference that shows up is the one I'm trying to commit. It does seem like something is happening online. I wondered if the files being synced to dropbox was an issue, but pausing dropbox didn't make a diff. – Annika Elsie Jan 06 '21 at 04:20

0 Answers0