I've run into two problems lately with using Git with a network drive.
First, I use RStudio with R projects that contain a Git repository. Some of these projects are stored on a network drive. This is a shared drive that has a sort of odd file path (as described in this question). As I wasn't sure how to map a network ("UNC path") to a folder (the suggested solution), I poked around to see what else might get it to work.
I ended up running RStudio as administrator. This allowed me to set the project as having Git (before, when running as non-administrator, this gave a useless error message saying "function error"). Once I set the global options to project having version control, RStudio created a new .Rproj file, restarted itself, and then the Git tab appeared in RStudio. When I opened the .RProj file again I did not need to run as administrator.
Second, I wanted to run Git in a folder located on a network drive by right-clicking in the repository folder on "Git Bash". This brings up Git Bash, but it says "CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows directory." I found that I could cd there, but I had to copy the file path from the Windows file explorer window, and then change all the slashes to forward slashes (/) from the Windows default back slashes (\).
Showing posts with label version control. Show all posts
Showing posts with label version control. Show all posts
Tuesday, May 21, 2019
Tuesday, January 17, 2017
Git Large File System
One of my projects needs some pretty big datasets that github can't handle by itself. Its error message helpfully suggested I install Git Large File System (LFS).
So, I downloaded and installed it. Then you need to initialize it. I tried it first in the git shell from RStudio but that didn't work (said it was not a command), so I tried opening a regular command prompt. There "git lfs install" worked (it said "Git LFS initialized").
Next, I needed to track some giant .csv files, but I didn't want to track all .csv files. The main instructions for using LFS call for tracking given file extensions.
This part was me noodling around and it didn't work, but has other ideas that might work for other situations. I found a modification for a single file tracking though, so I can track only some files by putting them in a folder (all the big ones). I tried following instructions for uploading a file here, but nothing happened when I tried the first file. I realized it might be too small, so I put a bigger file in (>100 MB) and it still didn't work. I tried just doing a single file and that didn't do it. ls-files and lfs status still doesn't show it. Modifying just to do all .csv files seems to modify them, which is not what I wanted. So I went back to the last good version (using git reset --hard SHAnumber). Unfortunately, somehow reset kept locking up RStudio. I finally got it to open when I paused my computer's Dropbox syncing (I was on a very slow connection) and also opened the project not from the recent projects menu. Not sure if one or both of those helped. Then I got the .csv files that had been modified to go away when I deleted the .gitattributes (not my custom.gitattributes file) that had LFS settings in it (apparently track/untrack just writes to .gitattributes).
Once I was reset back to where I was before I started messing with everything, I tried again with tracking the folder AND ITS CONTENTS. This does it!
git lfs track "myfolder/**"
However, it won't show anything staged in regular git status or git lfs ls-files until commited. you have to do git lfs status.
So, I downloaded and installed it. Then you need to initialize it. I tried it first in the git shell from RStudio but that didn't work (said it was not a command), so I tried opening a regular command prompt. There "git lfs install" worked (it said "Git LFS initialized").
Next, I needed to track some giant .csv files, but I didn't want to track all .csv files. The main instructions for using LFS call for tracking given file extensions.
This part was me noodling around and it didn't work, but has other ideas that might work for other situations. I found a modification for a single file tracking though, so I can track only some files by putting them in a folder (all the big ones). I tried following instructions for uploading a file here, but nothing happened when I tried the first file. I realized it might be too small, so I put a bigger file in (>100 MB) and it still didn't work. I tried just doing a single file and that didn't do it. ls-files and lfs status still doesn't show it. Modifying just to do all .csv files seems to modify them, which is not what I wanted. So I went back to the last good version (using git reset --hard SHAnumber). Unfortunately, somehow reset kept locking up RStudio. I finally got it to open when I paused my computer's Dropbox syncing (I was on a very slow connection) and also opened the project not from the recent projects menu. Not sure if one or both of those helped. Then I got the .csv files that had been modified to go away when I deleted the .gitattributes (not my custom.gitattributes file) that had LFS settings in it (apparently track/untrack just writes to .gitattributes).
Once I was reset back to where I was before I started messing with everything, I tried again with tracking the folder AND ITS CONTENTS. This does it!
git lfs track "myfolder/**"
Tuesday, September 20, 2016
Basic version control with Git and GitHub in RStudio in both Windows and Ubuntu
I don't remember why, but a few months ago I decided I finally had to try out this "version control" thing. I love it SO MUCH. Github and git can be a bit confusing initially, especially as I had the added layers of making it work with RStudio and on two different operating systems, but now that I've got it going it's great.
I started and installed git with this tutorial for starting with RStudio and git/github on Windows. To understand how push and pull work (as this confused me), I read through several pages. I started with this graphic of the workflow. That one ignores RStudio and is just about git and github. This essay has great illustrations and more details (code to use in the shell/terminal in RStudio). Finally this one is github/git only (no RStudio) but I still found it helpful to read about push/pull/branching in yet another way.
Next problem was that when I opened up my project on Ubuntu, git said all lines in files were modified when I had not actually changed all lines. This turned out to be an issue between line endings in Windows and linux type systems, and this would hide any actual changes if I had just made a few, so just committing every time was not a good option. I decided to go with adding a gitattributes file in each repository (so all users will get the same line endings regardless of who I share with). I added a gitattributes file (I combined general settings and the R settings available here) into the main project directory. For a directory that I had already used a lot (so lots of files with the wrong line endings) I followed these steps for the per-repository settings, including opening a shell in RStudio to input their code for refreshing my repository. (I backed up on a separate hard drive first in case I totally messed something up.) At first this didn't work, because I have a dual-boot situation, not using the files in two separate computers, according to this top answer. I ran the two lines of code in the top answer's update and that fixed it.
$ git config core.eol lf
$ git config core.autocrlf input
Finally, when I tried pushing in RStudio to github, I kept getting two errors:
error: unable to read askpass response from 'rpostback-askpass'
fatal: could not read Username for 'https://github.com': No such device or address
As I had already done the git config steps to add my github username and github email address, I looked up the error and found that I needed to create a private/public key pair because RStudio has issues authenticating apparently. I followed the top answer's links, which resulted in my changing the url in the .config file and then generating and linking an SSH key. I did this on both Ubuntu and Windows following the same instructions, resulting in two new key pairs (one for Ubuntu, one for Windows).
2016/11/04 edit: I got the askpass response error again in a new repository, but on the same computer that already had the SSH keys. In this case I only changed the url in the .config file and then it worked swimmingly. I've also had consistent success with line endings using the custom .gitattributes file followed by the two git config commands above.
I started and installed git with this tutorial for starting with RStudio and git/github on Windows. To understand how push and pull work (as this confused me), I read through several pages. I started with this graphic of the workflow. That one ignores RStudio and is just about git and github. This essay has great illustrations and more details (code to use in the shell/terminal in RStudio). Finally this one is github/git only (no RStudio) but I still found it helpful to read about push/pull/branching in yet another way.
Next problem was that when I opened up my project on Ubuntu, git said all lines in files were modified when I had not actually changed all lines. This turned out to be an issue between line endings in Windows and linux type systems, and this would hide any actual changes if I had just made a few, so just committing every time was not a good option. I decided to go with adding a gitattributes file in each repository (so all users will get the same line endings regardless of who I share with). I added a gitattributes file (I combined general settings and the R settings available here) into the main project directory. For a directory that I had already used a lot (so lots of files with the wrong line endings) I followed these steps for the per-repository settings, including opening a shell in RStudio to input their code for refreshing my repository. (I backed up on a separate hard drive first in case I totally messed something up.) At first this didn't work, because I have a dual-boot situation, not using the files in two separate computers, according to this top answer. I ran the two lines of code in the top answer's update and that fixed it.
$ git config core.eol lf
$ git config core.autocrlf input
I now copy the custom attributes file into any new R repository I have, run those two lines, and haven't had any problems going between operating systems now. Keep in mind this is where I have two different operating systems accessing the SAME FILES on the SAME drive/partition. If I understand correctly the gitattributes file should work fine without the extra lines if you have different computers, but I have not yet tested this.
Finally, when I tried pushing in RStudio to github, I kept getting two errors:
error: unable to read askpass response from 'rpostback-askpass'
fatal: could not read Username for 'https://github.com': No such device or address
As I had already done the git config steps to add my github username and github email address, I looked up the error and found that I needed to create a private/public key pair because RStudio has issues authenticating apparently. I followed the top answer's links, which resulted in my changing the url in the .config file and then generating and linking an SSH key. I did this on both Ubuntu and Windows following the same instructions, resulting in two new key pairs (one for Ubuntu, one for Windows).
2016/11/04 edit: I got the askpass response error again in a new repository, but on the same computer that already had the SSH keys. In this case I only changed the url in the .config file and then it worked swimmingly. I've also had consistent success with line endings using the custom .gitattributes file followed by the two git config commands above.
Subscribe to:
Posts (Atom)