Skip to contentSkip to conversation

Newbie in Git. How to get back from last pull?

DISCUSSION Yankovsky 4 participants 6 messages Jun 15, 2016

lore
Share & tools
lore

Yankovsky

author
#0 lore raw

Hi!
I have commited all my changes, and accidently typed git pull, then was paniced and aborted the operation. now all my changes in project disappear. but i have commit. how can i restore my project status using this commit? I hope you understand my rus english)
Thanks.

Signature · 2 lines
View this message in context: http://git.661346.n2.nabble.com/Newbie-in-Git-How-to-get-back-from-last-pull-tp5360499p5360499.html
Sent from the git mailing list archive at Nabble.com.
#1 lore raw

Hi Yankovsky,

Quoted 4 lines · Yankovsky

I have commited all my changes, and accidently typed git pull, then was paniced and aborted the operation. now all my changes in project disappear. but i have commit. how can i restore my project status using this commit? I hope you understand my rus english)

I don't understand exactly what you want to do, but here are the basics- you can decide what you want to do.
1. Use git reflog to see a history of your operations.
2. If you want your working copy to switch to an existing commit, use git checkout <SHA1 of commit>.
3. If you want to irreversibly destroy everything and switch your working copy to a desired commit, use git reset --hard <SHA1 of commit>. Use with care!

Hope that helps.

-- Ram

author
#2 lore raw

Ramkumar, thank you!
it works!
Awesome)

Signature · 2 lines
View this message in context: http://git.661346.n2.nabble.com/Newbie-in-Git-How-to-get-back-from-last-pull-tp5360499p5360639.html
Sent from the git mailing list archive at Nabble.com.
#3 lore raw
In reply to Ramkumar Ramachandra
Quoted 8 lines · Ramkumar Ramachandra

I don't understand exactly what you want to do, but here are the basics- you can decide what you want to do.
1. Use git reflog to see a history of your operations.
2. If you want your working copy to switch to an existing commit, use git checkout <SHA1 of commit>.
3. If you want to irreversibly destroy everything and switch your working copy to a desired commit, use git reset --hard <SHA1 of commit>. Use with care!

... and: 0. In "emergency recovery situations", _back up your whole source dir (including .git subdir) somewhere else before screwing around_!

E.g., "cp -a my_src_dir /somewhere_else/my_src_dir_backup"

-Miles

Signature · 2 lines
Pray, v. To ask that the laws of the universe be annulled in behalf of a
single petitioner confessedly unworthy.
author
#4 lore raw

yes, i did this)
Guys, thanks a lot!
really, i didn't expect help this quick!

Signature · 2 lines
View this message in context: http://git.661346.n2.nabble.com/Newbie-in-Git-How-to-get-back-from-last-pull-tp5360499p5360649.html
Sent from the git mailing list archive at Nabble.com.
#5 lore raw
In reply to Miles Bader
Quoted 10 lines · Miles Bader
Quoted 8 lines · Ramkumar Ramachandra

I don't understand exactly what you want to do, but here are the basics- you can decide what you want to do.
1. Use git reflog to see a history of your operations.
2. If you want your working copy to switch to an existing commit, use git checkout <SHA1 of commit>.
3. If you want to irreversibly destroy everything and switch your working copy to a desired commit, use git reset --hard <SHA1 of commit>. Use with care!

Quoted 3 lines

... and: 0. In "emergency recovery situations", _back up your whole source dir (including .git subdir) somewhere else before screwing around_!

IMHO the very first step should be to run "git status" and see what it says. With that information it would be much easier to recommend further steps.

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."