I deleted a file by mistake in the company and submitted it to the remote repository. Now I want to get the file back without changing other changes. What can I do?
黄舟2017-05-02 09:53:46
It’s very simple, you know which submission it is in, just use it
git checkout xxxxx lost_file
That’s it. Here xxxx is the sha-1 number in the git library.
大家讲道理2017-05-02 09:53:46
Switch to the previous commit, copy the accidentally deleted file, then create a new branch and paste the commit.
某草草2017-05-02 09:53:46
View commit_idgit log $filename
git log $filename
重置文件git reset $commit_id
恢复文件git checkout $filename
Reset file
git reset $commit_id
🎜Restore file🎜git checkout $filename
🎜習慣沉默2017-05-02 09:53:46
You can retrieve the lost file by deleting the previous submission ID of the file locally or get it back from the remote end, then add, commit, and push to the remote end again, which means that one more submission and push will be generated, and getting the file back is just one step. Louda's answer, git checkout commit id -- delete file path