Restoration of locally deleted files due to GitHub issues

Source: Internet
Author: User

After a long time, after GitHub commit, I manually deleted a local file and found that it could not be recovered. The file still exists in the remote database. That is, I want to return the files of the remote database to the local deleted location.


Specifically, after I add a file on the GitHub official website, pull will update the file to the local device.

However, the deleted local file cannot be recovered.



I checked it on the Internet. In fact, only one article actually mentions using the checkout file. The rest are directly copied, and I won't even describe a reprinted copy.


Indeed:

F: \ mygithub \ javaprogram \ util [Master + 0 ~ 0-1]> git checkout
D util/testtimer. Java


Next, you only need:

Git checkout testtimer. Java
// The above figure shows that your current directory is in util. Otherwise
// Error: pathspec 'testtimer. Java' did not match any file (s) known to git.
// Remember to add the specific path


I thought that the file was still not recovered during this step.


It may be because I submitted it again after deletion.

A git reset -- hard head will be submitted and reset will be found in the forum later.

Finally, it was restored using git checkout testtimer. java.


If all files in the folder are deleted,

You only need git checkout util (Folder name ).


If you don't want to do that, directly clone is a good choice.


Restoration of locally deleted files due to GitHub issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.