Git broken: git add. gives error: short read No such file or directory

0

I do not know why but at a time when I tried to add my progress to my deposit I had:

(MoodEnv) mike@mike-thinks:~/Programing/Rasa/Moodbot$ git add .
Bus error (core dumped)

Then I try again but it tells me that a file already exists:

(MoodEnv) mike@mike-thinks:~/Programing/Rasa/Moodbot$ git add .
fatal: Unable to create '/home/mike/Programing/Rasa/Moodbot/.git/index.lock': File exists.

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.

That's why:

(MoodEnv) mike@mike-thinks:~/Programing/Rasa/Moodbot$ rm .git/index.lock 

    error: short read No such file or directory
    error: MoodEnv/lib/python3.5/site-packages/libfuturize/fixes/__pycache__/fix_UserDict.cpython-35.pyc: failed to insert into database
    error: unable to index file MoodEnv/lib/python3.5/site-packages/libfuturize/fixes/__pycache__/fix_UserDict.cpython-35.pyc
    fatal: updating files failed

Update 05/31/2018

I'm not sure that's what worked, but he did:

rm -f ./.git/index.lock

And now he says:

(MoodEnv) mike@mike-thinks:~/Programing/Rasa/Moodbot$ git add .
(MoodEnv) mike@mike-thinks:~/Programing/Rasa/Moodbot$ git commit -m "milestone : ready to work, don't forget to add the true credentials"
[master 5db6840] milestone : ready to work, don't forget to add the true credentials
 19 files changed, 2127 insertions(+), 524 deletions(-)
 rewrite models/dialogue/policy_1_KerasPolicy/featurizer.json (92%)
 rewrite models/dialogue/policy_1_KerasPolicy/keras_arch.json (100%)
 rewrite models/dialogue/policy_1_KerasPolicy/keras_weights.h5 (73%)
(MoodEnv) mike@mike-thinks:~/Programing/Rasa/Moodbot$ git push origin master
Username for 'https://github.com': antoinecomp
Password for 'https://[email protected]': 
Counting objects: 23662, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (20906/20906), done.
Writing objects: 100% (23662/23662), 392.91 MiB | 1.41 MiB/s, done.
Total 23662 (delta 3553), reused 11501 (delta 2261)
remote: Resolving deltas: 100% (3553/3553), completed with 13 local objects.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 18f9ed182009e2704aa994c425387a10
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File MoodEnv/lib/python3.5/site-packages/en_core_web_md/en_core_web_md-2.0.0/vocab/lexemes.bin is 123.03 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File MoodEnv/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so is 112.42 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/antoinecomp/moodbot4.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/antoinecomp/moodbot4.git'

It seems that the reason why it does not work is because of a file that weighs more than 100Mb. It's strange because I thought I added them all in the .gitignore but maybe one was added. Here is the .gitignore :

/MoodbotEnv/*

Attempting to remove large files that have ever gone through version control by following this answer I got:

mike@mike-thinks:~/Programing/Rasa/Moodbot$ git rev-list --objects --all |\ 
 git cat-file --batch-check='%(objectsize) %(rest)' |\ 
 awk '$1 >= 100 * 2^20' |\ 
 sort --numeric-sort --key=1 |\ 
 numfmt --field=1 --to=iec-i --suffix=B --padding=7 --round=nearest
 112MiB MoodEnv/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
 123MiB MoodEnv/lib/python3.5/site-packages/en_core_web_md/en_core_web_md-2.0.0/vocab/lexemes.bin

But to eliminate that file from the story forever, it does not work as in the answer, there seems to be some commitment to do:

mike@mike-thinks:~/Programing/Rasa/Moodbot$ git filter-branch -f --index-filter 
'git rm --cached --ignore-unmatch 
MoodEnv/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so' HEAD
Cannot rewrite branches: Your index contains uncommitted changes.
    
asked by ThePassenger 30.05.2018 в 14:31
source

2 answers

3

Your problem is that you are trying to push files that weigh more than 100Mb and github does not allow that. Going further, you do not have to have project dependencies under version control.

It would be wiser to remove those files from version control by adding MoodEnv to .gitignore and delete them with git rm --cached -f MoodEnv .

However, you already have those versioned files, so even if you remove them, they are still in your history and when you push they will try to upload the reference to those files just because they were once versioned.

The solution would be to do

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch MoodEnv' HEAD

Review this answer for the entire procedure.

When removing the content of your virtualenv from version control, the rest of the collaborators will have to recreate the virtualenv when they want to work on the project. For that you will have to have versioned the file requirements.txt with the dependencies.

pip freeze > requirements.txt
git add requirements.txt
git commit requirements.txt -m "añade requirements.txt"

And then your collaborators, if they do not have the virtualenv directory, would have to create it and install the dependencies (for example with venv ):

python3 -m venv "MoodEnv"
source MoodEnv/bin/activate
pip install -r requirements.txt

And repeat the pip install each time a dependency is added to the project.

    
answered by 31.05.2018 / 13:55
source
0

A solution if you have the project uploaded to a repository is to make a clone of the project, take the file .git and from there you do the commit.

  • You delete the .git that you have or better, you copy it changing its name in case you find a more optimal solution.
  • Clone the repository back into another folder with a different name.
  • You copy the git of that repository, to which the git command does not work correctly, where you can already do the mythical commands.

    git add.

    git commit -m ""

  • answered by 31.05.2018 в 08:58