Github setup correctly but nothing in remote directory

Hi. As far as I can tell I've correctly setup an RStudio project linked to a Github. I've done this successfully before and it pushes fine, but with this one it commits/pushes seemingly correctly, but there's nothing at the github destination when I check. Please see photos - can anyone suggest any diagnoses?

Apologies if this is the wrong place. Rstudio + R + git + Github = not sure where to post!!


[Can only post 1 picture so here's an imgur album of the 3 of them: screenshots]

Where are the scripts being saved in your local machine?

I would type ls or dir (windows) to see if in the terminal it lists all the R scripts, if not then you might have initialized the git directory in the wrong directory.

1 Like

Hey man, thanks for the quick reply. Scripts are saved in the same place as the .git folder:

Now created Data man & R folders per good practice & moved scripts to R folder but AFAIK various files should be syncing nonetheless...? Tried commit push & files still not synced :frowning:

Re: ls/dir: presumably it'll list em if I change directory to their folder but I suppose that's no guarantee that they're in the right place, per se!

Thanks for any further thoughts.

If anyone else has any ideas I'd be most grateful. Cheers!

It is very hard to debug such things via screenshot. But I see two different paths in play: "blah blah blah ... Farallon Institute" vs. "blah blah blah ... Farallon Institute/Code", which seems odd. I would look into that.

I also note that you've got two things going on that increase degree of Git difficulty: spaces in the path ("Farallon Institute") and a Git repo that also is managed by DropBox. I have no idea if they are contributing to your difficulties, but they probably will one day!

Great observations, thanks Jenny.

  1. Manual rename Code.Rproj to FarallonInstitute.Rproj in the hope that aligning names makes it magically work: FAIL.
  2. FI/ vs FI/code: shouldn't be a problem I don't think: the code files themselves are in FI/Code, now with new Rproj name; the online location is SimonDedman/FarallonInstitute. This won't be a problem if Rstudio/git/github is ok with files being in a folder with one name, the project being a second name, and the github being a third, e.g. foldername/Code.Rproj -> github/user/ThirdName.git so long as the Code.Rproj's config file url line is pointing to the right place i.e. github/user/ThirdName.git. I've since changed the project name to match the github one but the config file is the same i.e. correct.
  3. Dropbox hasn't caused any problems so far with a separate project but you may be right in future!

Back to 1: I realised that changing the filename from Code.Rproj to FarallonInstitute.Rproj hasn't changed the name of the project from Code. It transpires Rstudio/git really does use the folder name that the Rproj file and .git folder etc are in as the project name. Changed folder name to FarallonInstitute, reopened RStudio, loaded Rproj, project name is now FarallonInstitute. Made a change, committed, but push option greyed out. This at least is progress.

Googled it, this (can't post links) says try "git push -u origin master" from shell then restart Rstudio. Tried in git bash in FI/FI folder, result:

$ git push -u origin master
 ! rejected        master -> master (fetch first)
error: failed to push some refs to ''
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 pull origin master
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

git push -f origin master
Counting objects: 24, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (23/23), done.
Writing objects: 100% (24/24), 5.77 KiB | 1.44 MiB/s, done.
Total 24 (delta 8), reused 0 (delta 0)
remote: Resolving deltas: 100% (8/8), done.
To GitHub - SimonDedman/FarallonInstitute: Farallon Institute work scripts

  • 10b33bd...d332c94 master -> master (forced update)

Seemed to work. Restarted github, made minor edit, commit fine, push still greyed out.

git push -u origin master
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 416 bytes | 416.00 KiB/s, done.
Total 4 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
   d332c94..5ab6f00  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

Restart github, nothing to commit, push no longer grey, pushed:

>>> C:/Program Files/Git/bin/git.exe push origin refs/heads/master
Everything up-to-date

WORKED, hooray! Wow what a lot of work for something seemingly so simple. Can't help feeling there must be a better way to have Rstudio/git/github work together but hey ho, sorted now and thus probably for the next year!