Anyone knows Git? I think I deleted my project usi...
# random
j
Anyone knows Git? I think I deleted my project using terminal but I did not push nor pull, I think I can recover it but don't know how to, someone can help me out?
s
how much of it did you delete
if
.git
is still there you can always
git checkout .
will restore the current state to the most current commit
j
I don't know how I deleted it, I just created a repo in Github, added a readme created add remote with that link and then tried to push
s
do you have at least one commit locally?
j
Yes
s
a git checkout should bring everything back
j
No, it does not 😞
s
what does your git log show?
j
I just see this
Copy code
commit 4832ca2b964b252a20f16ef6e144a5807bc215 (HEAD -> master, origin/master)
s
does git status say everything’s clean or
j
Copy code
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .idea/

nothing added to commit but untracked files present (use "git add" to track)
s
it almost seems like you made your initial commit after deleting everything
sanity check question - are you in the correct directory?
j
Yes, I did a
git commit -m "First commit"
with everything
The thing is how do I return to that commit
Yes, I am
s
if git status isn’t dirty and there isn’t a commit to fast-forward to, that would indicate that git thinks it’s at that commit you made
did you do a
git add
before committing?
j
yes
git add .
s
do you still have your remote add and push commands in your history?
j
How do I check that?
s
like, your shell history
history | less
if you want to page through it
or just press up a bunch of times to scroll manually
j
I put git log
And I see my initial commit
How can I go back to it?
s
you can just
git checkout $sha
to check out a specific commit