I'm working with git on Github with a C project. I have done the following in this order:
- Codding existing and new
.cppand.hfiles. Also added a big.stlfile. - Add the new files to git
- Create commit "A" with this changes
- Tried to push commit "A" to Github. It didn't let me push the commit because a file of 121MB had been added, which is more than the Github limit.
- Used the
git reset --mixedcommand so that I could undo the commit "A" containing the large file, add that file to .gitignore, and recreate a commit without that file.
Now the changes contained in files that were already tracked have remained and I can re-commit them, but the newly added files in commit "A" are all gone.
Isn't the git reset --mixed command just undoing the commits without changing the files?
Is there any way to recover these files that I had just added to git and that have been deleted?
CodePudding user response:
Apparently, the action that hides behind your IDE's "reset commit" isn't git reset --mixed, and it resulted in files being deleted from your disk.
As said in the comments : you can use the reflog to find past commits.
run
git reflogto spot the sha for commitA(the faulty commit with the 121MB file)use whatever action you see fit to get files back from that commit :
git reset Agit checkout A -- file1 file2git restore -s A -W -- .orgit restore -s A -W -- file1 file2- ...
