Git-在本地删除了一些文件,如何从远程存储库中获取它们 [英] Git - deleted some files locally, how do I get them from a remote repository

查看:50
本文介绍了Git-在本地删除了一些文件,如何从远程存储库中获取它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经删除了PC上的某些文件,如何重新下载?

I've deleted some files on my PC, how do I download them again?

拉说:已经是最新的".

Pull says: "Already up-to-date".

推荐答案

由于git是分布式VCS,因此您的本地存储库包含所有信息.无需下载;您只需要从指尖提取所需的内容即可.

Since git is a distributed VCS, your local repository contains all of the information. No downloading is necessary; you just need to extract the content you want from the repo at your fingertips.

如果您尚未提交删除操作,只需从当前提交中检出文件即可:

If you haven't committed the deletion, just check out the files from your current commit:

git checkout HEAD <path>

如果已提交删除,则需要从具有文件的提交中检出文件.大概是上一次提交:

If you have committed the deletion, you need to check out the files from a commit that has them. Presumably it would be the previous commit:

git checkout HEAD^ <path>

,但是如果它是n之前的提交,请使用HEAD~n,或直接启动gitk,找到适当提交的SHA1,然后将其粘贴.

but if it's n commits ago, use HEAD~n, or simply fire up gitk, find the SHA1 of the appropriate commit, and paste it in.

这篇关于Git-在本地删除了一些文件,如何从远程存储库中获取它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆