0

I have accidentally deleted all stylesheet files of my website.

I'm using git but I don't push changes to any repo. I just make commits on my development copy. So there is no repo to checkout from.

So what I did was, I had a backup copy of my site (it's old and doesn't contain all the files) so manually copy pasted all the stylesheet files to my development copy.

Is there any way to restore all that's gone?

4
  • To amplify David's note - your local project is a repo, just not a remote one. So if you've committed all those changes, and you still have your .git folder, do a checkout and you'll get it all back. (You need to be very careful when doing a "copy and paste" restore that you don't overwrite that hidden folder!) Commented Aug 7, 2012 at 11:36
  • I'd move the backup files you've just added, outside the repo, since they are old and are not as good as the files in your repo. Use git status to determine which these are. Then do the checkout above. Commented Aug 7, 2012 at 11:38
  • Oh,i thought checkout command is for downloading files from repos. Commented Aug 7, 2012 at 11:38
  • Only download is git fetch, download and merge is git pull which is a serial combination of git fetch and git merge. See man page. Commented Aug 7, 2012 at 11:50

2 Answers 2

4

If you ever added and committed the files into your development Git repository you can go back in history via git checkout HASH. This command will load all files with the state at the time of the HASH into the working directory. You can also pick specific files at a specific state; try git checkout HASH -- filename. If you accidently removed a commit that contains the relevant files you can lookup the total history of all Git actions via git reflog and kind of "revert" the state of your repository. In any cases make a copy of your repository before you start!

If you never added the files to the repository you can use one of the file system tools to undelete the files. The application choice depends on the operating system you use.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use git checkout /path/to/file, this will restore the files as they were at the last commit.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.