stat157 / questionnaire

Stat 157 Questionnaire Data Wrangling
1 stars 23 forks source link

How do I undelete a file after deleting git repository and pushing to github? #48

Open alexchaomander opened 11 years ago

kqdtran commented 11 years ago

Since you already push it to github, just clone it back to your local VM :D git clone https://github.com/YOUR_ACCOUNT_NAME/questionaire.git

aculich commented 11 years ago

@kqdtran The answer is a little more complicated than that... it is a file that was deleted both locally AND the deletion was pushed to github... so it's not just a matter of simply pulling from github to recover the deleted file.

@alexchao56 Did you ever get an answer to your question on stackoverflow? Can you post a link to your SO question here so we can all see if an answer shows up?

kqdtran commented 11 years ago

@aculich Oh I see, I thought Alex's question was getting back the file he already pushed to github...

In that case, I think git checkout would work?

Edit: a relevant StackOverflow question http://stackoverflow.com/questions/3150394/how-to-undelete-a-file-previously-deleted-in-gits-history. git checkout <commit> <filename> is what the top answer says. To get a list of commits, I suppose we can do git log?

alexchaomander commented 11 years ago

This is the SO post that I put up. It seems that a solution is to checkout the file in question and then recommit it again.

http://stackoverflow.com/questions/19215393/how-do-i-undelete-a-file-after-git-rm-and-pushing-to-github

aculich commented 11 years ago

You submitted the question at 2013-10-07 00:03:17Z and the first answer appeared at 2013-10-07 00:28:32Z and was the right answer for what you needed. That's ~25 mins! You increase your chances of success by submitting to StackOverflow and you also save effort, frustration, and can focus on other things (take a stretch break, go eat something, work on another part of the problem) while you're waiting for an answer.

I hope this will encourage you to submit another question to SO again!

IMPORTANT: Also make sure you accept the best answer (it will appear with a green checkmark when you do) so the person who answers your question will be rewarded with points for the effort they spent answering it. The points add up and actually are valuable. Employers do look at your SO history to see how well you ask and answer questions! It is a great way to get an edge over other people in the job market when you're interviewing. The SO point system is a factor.