Reputation: 17
I have 7 files on my git hub branch. i deleted 4 of them and made commit, but did not push. Now, I want those 4 deleted files back. other branch have same data and i tried merging, it says ' branch is updated ' but wont show those 4 files. I tried pull, and there is no help.
Upvotes: 0
Views: 73
Reputation: 665
Use following commands if you have not pushed yet.
If you want your changes in staging area (ready to commit) use
git reset --soft HEAD^
This will remove your commit which is not pushed and put the changes in staging. if your remove the changes with commit use hard as an option
git reset --hard HEAD^
Upvotes: 0
Reputation: 1470
There are two ways to get back those files:
1) if it's your recent commit then you simply reset its to get back your files.
git reset HEAD~1
2) if its older commit then you can revert it by
git revert your_deleted_branch_commit_hash
Let me know if it resolved the issue
Thanks!
Upvotes: 0
Reputation: 4335
You could find the commit when the file was deleted (it will log all deleted files and commits):
git log --diff-filter=D --summary
And then checkout the file:
git checkout <commit>~1 <filename>
Upvotes: 0