简体   繁体   中英

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

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" (ie 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM