mrblah
mrblah

Reputation: 103507

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?

Upvotes: 2

Views: 516

Answers (2)

CB Bailey
CB Bailey

Reputation: 791849

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

Upvotes: 6

Igor Zevaka
Igor Zevaka

Reputation: 76500

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

Upvotes: 1

Related Questions