How can I remove a commit on GitHub?
git log
git reset --hard ef2ef39d3c2842dd027b42fd96d7b3bc1db6e59d
git push --force
2:
git push -f origin HEAD^:master
3:
git push origin +7f6d03:master
git push -f origin HEAD^:master
SO link
Keep ignored files out of git status As I found here, .gitignore only works for untracked files. If you added files to repository, you can:
git update-index --assume-unchanged <file>
or remove them from repository by
git rm --cached <file>
then use rm
to delete the existing files (or folders) and push.
This article explains that too.
Also,
I've had this issue come up as well, it's probably because you added your ignored directory/files to .gitignore after they were marked as "to be tracked" by GIT in an initial commit flow.
So you need to clear the git tracking cache like so:
git rm --cached -r [folder/file name]
A more detailed explanation can be read here
The above command also removed the remnants of the folder/files from your remote GIT origin. So your GIT repos become clean.
SO link
Todo:
- add tracked files to gitignore
- try out other answers for deleting commits from github
read this later [https://stackoverflow.com/questions/3293531/how-to-permanently-remove-few-commits-from-remote-branch]