I have Problem: I wanted to commit something but instead commited the whole location where the folder which was meant to be commited were in. So now I have like way too many Files and folders in my Github and I really just want to get back to where I was before. That's why I tried hard reset, which I found online. So first I did "git log" and copied the hash of the HEAD I wanted to restore. Then I told my console "git reset --hard HASH" Of course I filled in my Hash where now stands HASH. After doing this whats o ever the files in git dont change online. I thought I might have to pull first and push then. I also tried to just commit and push. Still, no matter what I do, the files online won't change. Do you have any idea what I am doing wrong?
git hard reset - what am I doing wrong?
295 views Asked by HannahAround At
2
There are 2 answers
6
On
It sounds like you are trying to remove the remote branch and it's history.
I found instructions here: http://help.github.com/articles/removing-files-from-a-repository-s-history/
$ git rm --cached giant_file
#Stage our giant file for removal, but leave it on disk
$ git commit --amend -CHEAD
#Amend the previous commit with your change
#Simply making a new commit won't work, as you need
#to remove the file from the unpushed history as well
$ git push
# Push our rewritten, smaller commit
If you've described your flow correctly, you did these things in this order:
In that case, you would perform this.
WARNING: This is a good way to lose work. If you're working with others, be sure you have their blessing. If you're sure you want to do this, carry on.
This takes you back to the parent of where your HEAD reference is pointing.
You then would push the result of that to your remote branch.