-4

Attempting to pull the files back in again after deleted does not work. No files show following the second pull.

Why does git not pull the files in again?

thanks

Duke Dougal
  • 24,359
  • 31
  • 91
  • 123
  • 1
    If you want to undo the deletion, then you can use `git reset`: http://git-scm.com/docs/git-reset – Tom Sep 14 '14 at 02:13
  • I'm afraid the question lacks any hints that the author read a bit about git and especially `git pull`. – Pavel Šimerda Sep 14 '14 at 16:00
  • 1
    @DukeDougal as Pavel already indicated, your question makes it glaring obvious that you have read no documentation whatsoever. A question that shows no research effort will be downvoted. – Sascha Wolf Sep 15 '14 at 06:15

2 Answers2

1

Git doesn't again pull the file back in because you already pulled the files earlier and the local refs are all up-to date already.

In fact, since you've made a commit after deleting the files, your local master branch should be ahead of origin by 1 commit (which should be visible if you do a git status).

If you want your files back, you can use git reset or git revert like see other question, depending on your needs:

git reset --hard HEAD^

After running this, git pretends you never made the changes and created the commit. That's useful when you haven't yet pushed the commit back to the repository. If you accidentally drop a commit you actually needed, you can use git reflog to find it.

git revert HEAD

This creates a new commit which reverts the changes of the commit in question. This is useful when you already pushed the bad commit and you cannot pretend it didn't happen.

Community
  • 1
  • 1
Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186
-1

Git has already pulled in the files. They don't show up because your current commit has deleted them. You can go back to the previous commit without reverting/resetting this one using checkout command.

git checkout head^

Or you can checkout the upstream's commit as well:

git checkout blah/master

It will place you in a "detached HEAD" state. You can create a new branch out from that commit like so:

git checkout -b newbranch

You can always go back to the commit you made earlier by checking out master:

git checkout master
Sailesh
  • 25,517
  • 4
  • 34
  • 47
  • First two snippets result in a detached HEAD, which is by no means a beginner tool, the last get the user back to the situation he is asking about. – Pavel Šimerda Sep 14 '14 at 15:56
  • These are exactly the things that make people learn. I am not concerned about the level of his git skills. This is the answer to his question. Please let me know if the answer is wrong. Also, as you said, the last command brings him back to the situation because as mentioned above that, it is SUPPOSED to do exactly that. – Sailesh Sep 14 '14 at 16:03
  • 1
    Putting one's repository to a state with detached HEAD when it has nothing to do with what he actually wanted is IMO not a good way to help him with his learing. Unless I misunderstood the question, the OP wanted to recover from a bad commit deleting files, not to perform a useless exercise and then return to the wrong state with files deleted. – Pavel Šimerda Sep 14 '14 at 16:12
  • In my opinion the answer now covers what can be done using `git checkout -b newbranch HEAD^` or `git checkout -b newbranch blah/master` without using a detached head. I admit that the question is not very clear but my (and mu's) interpretation seems to be different from yours. – Pavel Šimerda Sep 14 '14 at 17:28