[英]After deleting a file from my local machine, how do I pull from github to obtain that file again?
Here is a chronological summary of what happened.以下是按时间顺序对所发生的事情进行的总结。
It's not up to date though.虽然它不是最新的。 test.csv still exists on github but not on my local machine.
test.csv 仍然存在于 github 但不在我的本地机器上。 How do I get this file back on my local machine?
如何在我的本地机器上取回这个文件? I assume there is something about how git works that I do not realize.
我认为 git 的工作原理有些我没有意识到。 Thank you for reading.
感谢您的阅读。
git pull
is used to "sync" your branch with the latest commits in the remote repository (GitHub). git pull
用于将您的分支与远程存储库 (GitHub) 中的最新提交“同步”。 It is not used to sync files .它不用于同步文件。
Since featurebranch
was never updated in the remote with new commits that you don't have, git pull
has nothing to do - there are no new commits to fetch and sync to.由于
featurebranch
从未使用您没有的新提交在远程进行更新,因此git pull
无关 - 没有新的提交可以获取和同步。 Your commit is the most up-to-date version of that branch.您的提交是该分支的最新版本。
If you want your file back, you can either git reset <older_commit>
the branch to some older commit that contained the branch.如果你想要你的文件,你可以
git reset <older_commit>
为包含该分支的一些较旧的提交。 Or you can git revert <the_commit_that_deleted_the_file>
the commit that deleted that file.或者您可以
git revert <the_commit_that_deleted_the_file>
删除该文件的提交。 Or you can git checkout <some_other_commit> -- test.csv
to selectively restore the file from <some_other_commit>
that contains the file.或者您可以
git checkout <some_other_commit> -- test.csv
选择性地从包含该文件的<some_other_commit>
中恢复该文件。 Or you can git checkout
or git switch
to some other branch/commit to change your working directory to a commit that actually had that file.或者您可以
git checkout
或git switch
到其他一些分支/提交,以将您的工作目录更改为实际具有该文件的提交。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.