开发者

deleted a file in local master branch, how do I get it back from the remote?

开发者 https://www.devze.com 2022-12-12 18:18 出处:网络
I deleted the default.aspx.cs file by mistake in my local master branch. 开发者_运维百科How can I get this file back from my remote repositories master?If you haven\'t staged or committed the deletio

I deleted the default.aspx.cs file by mistake in my local master branch.

开发者_运维百科How can I get this file back from my remote repositories master?


If you haven't staged or committed the deletion then a simple:

git checkout -- default.aspx.cs

will retrieve the file from the version in the index.

If you really need to go back to the remote master's version (which would only be different if you've staged or committed other changes to the file before deleting it), you can do:

git checkout origin/master -- default.aspx.cs


If you haven't "staged" (i.e. called git rm default.aspx.cs) then you can call git checkout:

git checkout Default.aspx.cs

If you called git rm Default.aspx.cs or git add -u then you can reset the file:

git reset -- Default.aspx.cs
git checkout Default.aspx.cs
0

精彩评论

暂无评论...
验证码 换一张
取 消