I had to move my documents and data from a dying computer to a new one. Unfortunately, that meant changing the directory locations. I think this has broken git. In every git registered project I no longer seem to have to the same already registered files and history of commits. Most of these projects are only local git repositories but two are ones I push to github. Sorry for a very git ignorant question but can anyone suggest how I can fix this? I have tried to search for answers but either they have heated debates between git afficionados or look plain wrong to me and I fear messing things up further. I have the same user name on the new machine as the old one and have transferred ~/.ssh from the old machine. The old machine ran Ubuntu 20.04 and the new one runs Mint 20.3, Rstudio is 2022.02.01 build 461 and git is 2.25.1. Happy to supply any other information. Thanks in advance. Chris
Can you say how you copied the folders ?
cp -R <source_folder> <destination_folder> ?
If so I wouldnt expect the breaking behaviour you describe, (I did a simple test, starting a project, enabling git, naively copying to a new path, and opening it up), but I grant you that strange things can happen.
Thanks very much for responding. I had to restore from a backup so the old location was /media/chris/internal_HDD/Data/morestuff and now it's /media/chris/Clevo_SDD2/Data/morestuff (where "morestuff" is saving you further structure that is the same in the old location and the new location). It would be a nightmare now to go back and change that "Clevo_SDD2" as it's the label on a luks encrypted drive so I think I'm stuck with that. I think the restore should have preserved all file attributes and the user was/is chris on both (and the drives were/are ext4 on luks). For the directories (there are several, low double figures), where the git repository has only ever been local I'm OK to just delete the whole .git structure which I assume will purge the repository and I think I could also purge the .proj files and then recreate things. Obviously, I'd rather not do that as I'd lose the history but I could live with that. For the two repositories that push to github I am much more keen to try to find a way to repair things. I think that can be done by pulling back from github in some way but I'd hate to mess that up. Sorry, long answer to a short help offer!!
I had to restore from backup so what was in /media/chris/internal_HDD/Data/... is now in /media/chris/Clevo_SDD2/Data/... and I would be a nightmare to change that "Clevo_SDD2" now. I am ordinary user chris on the new machine as I was on the old one and I think the restore should have preserved file attributes. I have low double figures of projects with git repositories and I could just delete the .git and .proj and rebuild and lose all their histories: sad but I can live with that. The two that pushed to github are more important. I think there is a way to pull the information down from github to recreate the local repositories but that sounds like a golden way for a git neophyte like me to mess that up and end up perhaps no longer able to push the work to github easily or else having to recreate the github repository copies and there the histories are more important so I'd hate to have to do that. I hadn't expected this!! TIA again to anyone!
On the backup copy issue, all i can think of is that maybe your backup had rules to exckide certain files from backup? Because git works by using a multitude of hidden files within the directory being git tracked. If the backup were to only watch non hidden files it wouldn't get the necessary parts...
On the github stuff you should be golden. Simply log onto gihub , find the repo and look for the green button to clone from (it should give you a url) and you can start a new rstudio project based on your githurb url , and pull the project from github to your local machine.
I agree with @nirgrahamuk that you may have lost the hidden files. If you allow the listing of hidden files (in the GUI use the menu View -> Show Hidden Files, in a terminal use
ls -a), do you see a .git directory?
Thanks both. Sorry for the delay. Bizarrely, I have had to change OS (from Mint to Ubuntu) but the location of these files is unchanged. I'll come back to the github gold option (!) as I'd like to keep that in reserve. However, the simple answer about the hidden files and folders is that they're all there. .git is there with its own folders and the restore was definitely restoring such files and folders. I wonder if the issue is in Rstudio not git. Hm, that got me to something I should have done already: use simple git from the command line Christopher! OK.
git config --list told me I didn't have my name and Email address presumably because I hadn't restored /home/chris because I thought too much there would be localised to the old machine. Easily fixed. Go to one of the folders with a project and .git,
git status gave me this:
root@Clevo1:/media/chris/Clevo_SSD2/Data/MyR/R/distill_blog/test2# git status fatal: unsafe repository ('/media/chris/Clevo_SSD2/Data/MyR/R/distill_blog/test2' is owned by someone else) To add an exception for this directory, call: git config --global --add safe.directory /media/chris/Clevo_SSD2/Data/MyR/R/distill_blog/test2
So I obeyed that and now it shows me that all the files have been modified which is presumably because I knitted the whole directory again. However, back in Rstudio it shows me all the files but won't let me do anything with them and if I ask for the history I get an empty area. I wonder if the issue is with Rstudio not git. If I got to Tools, Project Options I just get a spinner at the top saying "Reading options" and if I try to quit Rstudio after that I get another spinner saying "quitting Rstudio" (or something like that) but no quit unless I hit the close button again. That doesn't happen if I just open the project and then quit Rstudio: it just quits. The contents of the project file are:
root@Clevo1:/media/chris/Clevo_SSD2/Data/MyR/R/distill_blog/test2# cat test2.Rproj Version: 1.0 RestoreWorkspace: Default SaveWorkspace: Default AlwaysSaveHistory: Default EnableCodeIndexing: Yes UseSpacesForTab: Yes NumSpacesForTab: 2 Encoding: UTF-8 RnwWeave: Sweave LaTeX: pdfLaTeX BuildType: Website
This is a fresh install of Rstudio daily build #373 (I am having to use the daily build because of an incompatibility between the stable release and Ubuntu 22.04 (https://community.rstudio.com/t/rstudio-ide-desktop-2022-02-0-443-not-working-on-ubuntu-22-04-lts-some-gui-issue/135876/4 ... oh yes, I do pick these issues). However, this was happening with the stable release under Mint before.
I would love to hear any other suggestions and really appreciate the help.
I think you described a situation where you copied data from one machine to another, but your user id was different across the two, so you wouldnt have automatic file priviledges on the copied files ? If so then perhaps you can force it by using
chown or something similar to make your new user the owner of them
Thanks, yes, all started with a move all my data and documents to a new machine. User is the same as on the old machine and I look to be the owner with all the correct permissions.
total 212 4 -rwxr-xr-x 1 chris chris 73 Jan 27 2021 description 4 -rwxr-xr-x 1 chris chris 23 Jan 27 2021 HEAD 4 drwxr-xr-- 2 chris chris 4096 Jan 27 2021 branches 4 -rwxr-xr-x 1 chris chris 261 Jan 27 2021 config 4 drwxr-xr-- 2 chris chris 4096 Mar 25 08:46 info 4 drwxr-xr-- 2 chris chris 4096 Mar 25 08:46 hooks 4 drwxr-xr-- 5 chris chris 4096 Mar 25 08:46 refs 4 drwxr-xr-- 3 chris chris 4096 Mar 25 08:46 logs 4 drwxr-xr-- 260 chris chris 4096 Mar 25 08:47 objects 4 -rwxr-xr-x 1 chris chris 119 Apr 18 19:18 COMMIT_EDITMSG 164 -rw-rw-r-- 1 chris chris 164073 May 8 20:07 index 4 drwxr-xr-- 7 chris chris 4096 May 8 21:53 .. 4 drwxr-xr-- 8 chris chris 4096 May 8 21:53 .
SOLVED (but not really understood)
It turned out that I need to run
git add *
at the command line to get all the files that were marked as "not staged to commit" back into that "staged to commit" status. I don't understand this because I'm a git newbie but it has fixed the Rstudio spinner issue too.
One side thing I learned which I think was never causal in any of this (and which I probably should have guessed sooner when Rstudio complained it didn't know my identify for git): if you change/update your git ID:
git config --global user.email 'email@example.com' git config --global user.name 'Chris Evans'
you must do it as the user not as root as those things are stored per user.
Many thanks for support and pointers: invaluable for me through this.
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.