Find Lost Files
You have been working on a project in the git-playground
repository. However, you have noticed that some files are missing and you are not sure when they were deleted or how to recover them. Your task is to use Git to find any lost files and commits in the repository.
- Clone the
git-playground
repository:
git clone https://github.com/labex-labs/git-playground.git
- Navigate to the directory and configure the identity:
cd git-playground
git config --global user.name "your-username"
git config --global user.email "your-email"
- Create and switch a branch named
one-branch
, delete file2.txt
and commit with the message "Remove file2":
git checkout -b one-branch
git rm file2.txt
git commit -m "Remove file2"
- Switch back to the
master
branch and delete the one-branch
branch:
git checkout master
git branch -D one-branch
- Run the
git fsck --lost-found
command to find any lost files and commits:
git fsck --lost-found
- Check the
.git/lost-found
directory to see if any lost files were recovered:
ls .git/lost-found
- If any lost files were found, review them to determine if they are the missing files.
This is the result of running the ls .git/lost-found
command:
commit