Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
348 views
in Technique[技术] by (71.8m points)

git - After updating R and RStudio, push to GitHub fails stating remote is ahead even though it's not

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...