Reputation: 399
I added some old assignments to my GitHub. I added one assignment from my local repo to the remote successfully, but made the mistake of adding a README.md
to it on my web browser. This caused me to not be able to push any commits locally anymore because
Updates were rejected because the remote contains work that you do
not have locally. This is usually caused by another repository pushing
to the same ref. You may want to first integrate the remote changes
(e.g., 'git pull ...') before pushing again.
So I did a git pull origin master
command to get that README.md
file from GitHub, but I believe when it merged with my local branch, it deleted all of my local files that I had not pushed yet. Now all of my other assignments are just empty folders. How do I get these files back? And what would have been the better alternative to pulling from the remote repository?
Upvotes: 0
Views: 4390
Reputation: 1
You can ur files back in GIT > Shelf , if you're using Intellij its easy to find ur uncommitted changes.
Upvotes: 0
Reputation: 534893
How do I get these files back
Actions performed with git are undoable only to the extent that there is a commit reflecting the state you want to get back to. Only a commit is a "thing" in git.
So, if you did a git pull
and it had effects you don't like, you can git reset
back to the commit before you did the pull.
But if your action affected files that were not committed, then there is absolutely nothing you can do. Files that are not committed are no concern of git's.
Upvotes: 1
Reputation: 52488
You cannot get file README.md
at local. Because this file never staged to local repository.
You can get file README.md
at GitHub.com easily, because you just saved it, it has a commit hash string.
Upvotes: 1