1

I have added my code by

git add .

Now I have committed my code by

got commit -m "Added Filter"

Now when I have tried to push code by

git push

I have found that there is one file named java_pid12312.hprof whose size is more than 1 GB and so I have stopped git by Control + C

Now I have deleted that java_pid12312.hprof file from finder & from trash in Mac.

Now I tried again to push file hopping that file will not upload but still git is showing me to upload one large file, I have checked my whole source code there is no file whose size is more than 200 kb.

I thought that it might be in cache, so I have used below command to remove it from cache

git rm --cached java_pid12312.hprof

But it shows me error message like below

fatal: pathspec 'java_pid12312.hprof' did not match any files

How it is possible? I am sure that it is still trying to push java_pid12312.hprof which I have already deleted, is there any idea?

Siddhpura Amit
  • 14,534
  • 16
  • 91
  • 150

1 Answers1

4

Looks like the file has already been committed, and even though you have now removed the file it still exists in your history.

To remove it from your history, providing the push to the remote has not yet happened, you can do the following:

  1. git reset --soft HEAD^ (this will rewind by 1 commit, but preserve your files on disk, so you won't lose anything)
  2. rm -f java_pid12312.hprof
  3. git commit -m "New commit"
  4. git push
JamesHalsall
  • 13,224
  • 4
  • 41
  • 66
  • I can still see the same error. Tried exactly as you've suggested. Any workaround for this ? – sj_959 May 05 '21 at 11:33