0

I have a repository on bitbucket. I pulled the whole project on my friend's computer by this command:

$ git pull origin master

All fine. After some minutes I've removed (via Shift + Delete) some files of the project (.git folder is still there) by mistake. Now I want to pull the project again, but when I write command above, it throws this:

enter image description here

Anyway, how can I get the project again when I've already pulled it once?

Martin AJ
  • 6,261
  • 8
  • 53
  • 111

1 Answers1

3

I am assuming since you mention you deleted files by mistake, you want to revert back to the state the project was at before you deleted the files (to the state of the previous commit). If so, use the command git reset --hard

ryanlutgen
  • 2,951
  • 1
  • 21
  • 31
  • Yes it worked .. thank you, upvote, just one question: The link @Qamar provided in the comments *(under my question)* says I need to use this command first: `git fetch --all` *(before `git reset -- hard`)* .. but I didn't use that command and it worked. So can you please tell me what's the meaning of `git fetch --all` ? – Martin AJ Jan 04 '17 at 05:41
  • `git fetch` essentially updates the branches on your remote repository (origin) for your local repository. `git fetch --all` will do it for all of your remotes if you are working with multiple remotes (say you have a fork on a company server and on github). The top answer on that question is posting how to reset relative to a remote, not just locally, hence why they suggest fetching first. Doing a simple `git reset --hard` will reset your local HEAD to the latest commit, you can then fetch (and pull) after if you wish. – ryanlutgen Jan 04 '17 at 07:29