By chance, and my negligence, the test file of a rather large size, which should not have been there, got into the repository. I noticed this when I started pushing to the server.

In general, in the repository, I had a files directory, in which this test file, and a bunch of other still, unnecessary files.

In general, I made several decisions:

http://www-cs-students.stanford.edu/~blynn/gitmagic/intl/ru/ch05.html

http://dalibornasevic.com/posts/2-permanently-remove-files-and-folders-from-git-repo

http://www-cs-students.stanford.edu/~blynn/gitmagic/intl/ru/ch05.html

I'm interested in the question , after the instructions given on these links, the file is removed from the history, but the size of the repository remains the same as with these files in the index. Chyadt? Or so it should be, files, once added to the index, physically remain in the repository forever?

After these operations, the output of the git status command will be as follows:

: git status В ветке dev Your branch and 'origin/dev' have diverged, and have 1 and 1 different commit each, respectively. (use "git pull" to merge the remote branch into yours) нечего фиксировать, рабочая директория пуста 

Those. we have a discrepancy in the same commit on the server and mine. Question : how can I push my version with files deleted from history to the server? )

  • To delete files in history, use git filter-branch. You can use git push -f to force a particular turnip state to push. - etki
  • one
    Without the forced push "delete forever" file will not work. You can roll back at home, and then push this state forcibly. But if other people work with you in the company, they will not be happy (they will have to do forced pull). - KoVadim

2 answers 2

If you need to delete the file only from the remote repository, use the command

 git rm --cached mylogfile.log 

To remove a directory from a remote repository

 git rm --cached -r mydirectory 

After that, commit and run the changes to the repository. Files will remain in the local repository, and will be deleted from the remote one.

    Not quite sure if this will work for the remote repository, but try it .

     rm -rf .git/refs/original && git gc --aggressive