0

I want to add chromedriver file in my repo using git LFS. The steps I followed are:

  1. Install git LFS using this command:

    sudo apt get install git-lfs

  2. Initialize our repository with git-lfs using following command:

    git lfs install

  3. Track the files we want to add using this command:

    git lfs track chromedriver

  4. git add chromedriver

    It is giving this error: The following paths are ignored by one of your .gitignore files: savedrivers hint: Use -f if you really want to add them. hint: Turn this message off by running hint: "git config advice.addIgnoredFile false" How to fix it?

Secondly, what is the purpose of command git add .gitattributes?

Other questions:

  1. After the file is pushed in our repo, in which folder can we see the file and how can we access it inside our code?
  2. Will the size of our repo be affected after adding file with GitLFS? As the purpose of Git LFS is to store file in our repo without affecting its size.
  3. When the branch containing git lfs code gets merged to master branch, does everyone have to pull it locally?
  4. In Github LFS, instead of pushing the files in our repository, we push them in a different server, and then can only reference from inside the repository. How can we access it in our code?
Waleed Farrukh
  • 205
  • 1
  • 10

1 Answers1

1

It appears that your chromedriver file is in the savedrivers folder, which is marked as ignored in one of your .gitignore files. Either use the -f to force adding it, or remove savedrivers from .gitignore.

For the .gitattributes file, see this question and others on SO.

Other answers:

  1. Using git lfs is transparent for the end user. From your point of view, it is just like any file. Internally, git uses some smart mechanism, but generally users need not concern themselves with how exactly it is done, they can just treat it as any file. The only thing required it that the file is recognized as a binary LFS tracked file, which is done by adding a pattern to the .gitattributes file.

  2. The size of the overall repo will increase in the sense that if you clone it, you will get a large .git folder locally. You should find these files in the .git/lfs/objects folder. On servers such as GitHub, Bitbucket, GitLab, the objects are stored using special LFS-storage.

  3. There is no difference between binary files and text files from the end users' point of view. Binary / LFS files that are introduced in a commit get pulled like any other file. If someone commits a DLL, it will show up in the others' working folder when they check out a branch containing it.

  4. GitHub's internal workings and storage of files should be transparent. Users should push binary LFS-tracked files like any other file. When someone pulls a branch with references to binary files, those binary files will show up there in their working folder. The thing to pay special attention to is that EVERYONE from the team has properly configured GIT LFS on their system / repo, or else they might end up pulling only the references and not the actual binary files, or pushing binary files to the "proper repo" instead of the LFS area.

Gec
  • 428
  • 2
  • 10
  • Thanks a lot for your help! Really helpful answer! One thing more I want to ask: Once we have pushed a file using git LFS, now if we want to track another file using git LFS, do we have to rerun git lfs install? Or it has to be run once by every team member? – Waleed Farrukh Dec 06 '22 at 11:45
  • Another question, when I pushed a file in github by using git lfs, I can only see .gitattribute file changed under my commit in github like this: chromedriver filter=lfs diff=lfs merge=lfs -text Is it the only change that is expected? Now when my branch gets merged with master branch, can other team members be able to access that file simply by adding git pull origin master? Obviously after they have properly configured git LFS on their system. – Waleed Farrukh Dec 06 '22 at 12:12
  • 1
    Sorry for the delay, been away for a while. You probably figured it out by now, but still. git lfs install does the setup and generally needs to be run only once per system (once by every team member), see this conversation https://github.com/git-lfs/git-lfs/issues/3087 for some details and exceptions. In my original post I said that git is smart enough to detect binary files and add them to LFS. That is not correct, I apologize. You need to add them to the .gitattributes manually. – Gec Dec 09 '22 at 07:03
  • 1
    See this post https://stackoverflow.com/questions/61634011/is-it-mandatory-to-use-the-filter-attribute-for-git-large-file-storage-lfs-in for more details. My confusion was caused by the fact that on new repos I always look for a gitignore and a gitattributes file pre-populated for the project type I am tracking in that repo, so I somehow thought it was magic - it is not. I'll edit my original answer to not confuse others too. If each team member has set up git lfs and pulled the .gitattributes file, they should be good. – Gec Dec 09 '22 at 07:06