Quantcast
Channel: Git push doesn't ignore files in .gitignore - Stack Overflow
Viewing all articles
Browse latest Browse all 5

Answer by AD7six for Git push doesn't ignore files in .gitignore

$
0
0

The files are still in your git history. From what's in the question the git history is for example:

$ git log --onelineaaaaaaa Update .gitignore and remove big filesbbbbbbb accidentally add big files to repoccccccc update fooddddddd update bar

And pushing fails because of pushing the contents of commit bbbbbbb, it doesn't matter that the file is not in your currently checked out version it's in the project history.

The above can also be confirmed by checking for the history of a specific file/path:

$ git log --all --format=%H -- big.fileaaaaaaa Update .gitignore and remove big filesbbbbbbb accidentally add big files to repo

If big.file is large enough to prevent pushing to github - you need that list of commits to be empty

Obliterating a file from history

There are a number of ways to prevent attempting to push big.file to the remote, but based on the info in the question the simplest of which is:

$ git reset --hard ccccccc

This will remove commits aaaaaaa and bbbbbbb thus there will be no attempt to push big.file to the remote.

The purpose of .gitignore

.gitignore files affect adding files to the repository, they do not affect files already in the index. This is the reason that adding files to .gitignore has had no effect on 'the problem'.


Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>