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.
Asked
Active
Viewed 52 times
0
-
2Possible duplicate of [Find and restore a deleted file in a Git repository](https://stackoverflow.com/questions/953481/find-and-restore-a-deleted-file-in-a-git-repository) – phd May 18 '18 at 22:18
4 Answers
0
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>

muecas
- 4,265
- 1
- 8
- 18
0
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!

rahul mishra
- 1,390
- 9
- 16
0
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^

dr. strange
- 665
- 7
- 22