git如何回退单个文件误删
PHPz
PHPz 2017-05-02 09:51:46
0
5
1163

在公司误删了某个文件,已经提交到远程版本库,现在想将该文件找回来,其他改动不变,有什么办法?

PHPz
PHPz

学习是最好的投资!

reply all(5)
黄舟

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.

大家讲道理

Switch to the previous commit, copy the accidentally deleted file, then create a new branch and paste the commit.

左手右手慢动作

git stash pop can also be tried

某草草

View commit_id
git log $filenamegit log $filename
重置文件
git reset $commit_id
恢复文件
git checkout $filenameReset file

git reset $commit_id 🎜Restore file🎜git checkout $filename🎜
習慣沉默

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template