1
I have a folder on my machine, which when I update I commit to Github.
It turns out I made some good changes, and went to commit. I did:
git add -A
git commit -m "..."
git push -u origin master
Only I gave up sending it to git, so I pressed CTRL+C, but from there git showed the message saying I had 1 commit pending (ie my changes made on the day yet nay were on Github, only on PC).
In order to eliminate that message, I:
git reset hard
And finally when I typed git status
, no longer came the message saying that I had a pending commit.
But now my changes made to the PC (in the commit folder for git) had been undone, deleted files. Does anyone know how to make those files and changes go back to this folder on my PC?
I tried to git revert
but it just goes back to what was already on Github and, as I said at the beginning, those changes weren’t on Github because I didn’t expect to complete the command git push
, that is, those changes were only on the PC.
If you had already pushed the master, give a qit pull back on site...
– hugocsl
then, but I gave a Ctrl+c before the push was finished, and then revert, and what was left in git were other past changes
– André Oliveira
then give Ctrl+V to the Uai folder
– hugocsl
you got it wrong. Ctrl+c on the terminal when I was running the push -u origin master command, that is, I stopped the push. That’s it. It has nothing to do with copying and pasting kkk friend. In the text above I explain the step by step I did
– André Oliveira
https://www.youtube.com/watch?v=6OokP-NE49k This should help you
– hugocsl
Thanks friend, will help me to use git better. But apparently, the changes do not come back, since I had not sent to github yet. But thanks anyway, you’ll help me from now on.
– André Oliveira
The
git reset --hard
deletes all that it had previously saved, so it should be used with caution. But you did not pass the commit id before doing the--hard
?– Mateus Daniel
git reset --hard
in fact deletes local changes (see here more details on how it works), but maybe vc can still recover the commit: https://stackoverflow.com/a/21778– hkotsubo
I believe that can not reverse, I think you wanted to put the files in the area of stash
– Denis Rudnei de Souza
@Andréoliveira, not related to Git to my solution, but if she was using an IDE, she might still have in her history the files that were removed. In Intellij it looks like this: https://blog.jetbrains.com/idea/2008/01/using-local-history-to-restore-deleted-files/
– Dherik