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?
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