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?

7
  • 1
    If you check out the last commit (git checkout HEAD^) can you see the file then on the filesystem? Commented Apr 2, 2020 at 8:28
  • Git does not push files. Git pushes—and stores—entire commits at a time. If you are sending a commit that contains a 1GB file, that will take a while. Commented Apr 2, 2020 at 8:29
  • Yes it has taken so much time while performing command git add . Commented Apr 2, 2020 at 8:30
  • @JamesHalsall, Yes in history of my git it shows me that file Commented Apr 2, 2020 at 8:31
  • 1
    If it has not pushed to the remote yet, then you can rewrite history with git reset --soft HEAD^1, then remove the file, commit again, and then push Commented Apr 2, 2020 at 8:34

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

1 Comment

I can still see the same error. Tried exactly as you've suggested. Any workaround for this ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.