retrieve git commit never pushed

techie.brandon

I was working diligently on a large refactoring of some code, had a immediate need to resolve a fix in current codebase; I thought I made a commit in a branch named 'refactored' and did a switched back to my main branch to reset and branch off again. In doing so I never pushed commit to remote and seems likely that my reset ate the work I had done. I have tried to find the headless commit using reflog but am having trouble finding it. Is there a way I can more effectively search across all the files git knew about (ever!) so I can find this work? There are numerous files in there who were certainly "Added" to git and never would be in another branch or revision. Help!~! :)

With infused help I was able to get a list of the files I need to retrieve, but I am a little uncertain how to proceed without mucking up further.

git fsck --lost-found

Results in:

Checking object directories: 100% (256/256), done.
Checking objects: 100% (776/776), done.
dangling blob 8f20a05f00d77c78d10a3918d6d34a2d2c097624
dangling blob 47a10c7617b7cc9f8ba176050c5a3b79c54f102d
dangling blob 57716763518cc82585d614fa0a8ee591c8de1153
dangling blob b90129cb7ffe06fe23356e8fe7a1ad3b0e24d984
dangling blob d621cb1156dfdf79163d0072d03cfe5d05254b01
dangling commit 1bc2732eac1a8052dff64de96c7ecf38f11dc9c5
dangling blob 30e2b939f96737af80ac0326b5c5cd39a8de9ce7
dangling blob 4a2a3732e06511a26acd08a663fbfb671fdf0439
dangling blob 57f2ff859a88c069442961baf86b78312b80ab13
dangling blob 72ca95ac4e98e2d30677fe8d611ddcd30225d255
dangling blob 9022ffd961b57d713d20a93dc4cb51f1b94a5918
dangling commit bf1ae36f865ce066220024392dfbcc7a2fa359cf
dangling blob ec4272468be0f90f2b4b6416649e98101a20b015
dangling commit 134bf35bd24e7a7f4303279448c7cb0d33adcdb5
dangling blob b833b9c702b43c1682bfcb841ad7f8d87baabfb1
dangling blob c68b9511f2cd058603950ab630cad3b7935074aa
dangling blob 3a4caeaa63cf6d73f6071d5a8b4566d84cf55898
dangling blob 755cb36c73fd2d26e10711dc2ec221c039d805e7
dangling blob d914e5a277ac574f0b3ee414166977b8e2331b7b
dangling blob dd8c8338a4515b0b3f4b68340dbd10416e444eed
dangling blob e4f4d97b4f7c245a2f5b0ff9671404bea7e6ffc7
dangling blob f28c0bd9f0a4d59816bb0e052578e2a64b70feb6
dangling blob 1a557bdf7c6d9bd972b0f38eb074ed7875a632c3
dangling blob 3e0d0c77b6a47ee8f94a0d56416ee1d8833e89f0
dangling blob 81dd04f987303d080977df050b32865cbf29720f
dangling blob dd5d8e61e48343487189b1264e711a9d72bc1712
dangling blob e26599b870d9c9e3387e018f2d4467d31c8c5dc2
dangling blob 0607498a73ca5faf3b77a7c77107e7787c0f224f
dangling blob 251f0d0bea520723ccf15466cf9f047d0d94d48f
dangling blob 4ecfc189d8c61ff8033e02731bb88005e19f1ca9
dangling blob 6c87b890fc2ff4f13d5a6ffd15355b3c7a9be269
dangling blob bbaf45e48c21e2877c90a3864507ad56c52f6afe

Using:

git show 8f20a05f00d77c78d10a3918d6d34a2d2c097624

So the final solution was to pipe the output from git show to a file for each blob.

git show <SHA> >> ~/recovered/fileName.js
infused

If you did commit to the refactored branch you should be able to checkout that branch and find your commits intact. On the other hand, if you committed the change to master and then did a hard reset, you should be able to find the commit using lost-found. Depending on what version of git you are using:

git fsck --lost-found

Or

git lost-found

These commands should turn up a list dangling commits which you can run git show on to find your commit. It should be one of the top items in the list.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Check who pushed a Git commit

From Dev

change a git commit already pushed

From Dev

Check who pushed a Git commit

From Dev

When a commit was pushed into a remote Git Repo

From Dev

Change name in already pushed commit in Git

From Dev

Change the author of last commit in Git(pushed remotely)

From Dev

Deleting a local Git Branch that was never pushed - delete it on the server, too?

From Java

Undo a particular commit in Git that's been pushed to remote repos

From Dev

git: What is the "right way" to fix an incorrect pushed commit message

From Dev

Which git hook to use for validating pushed commit messages?

From Dev

how to remove a file from a git commit that has been pushed

From Dev

Git forgot to add file change to a not yet pushed commit (not the last one)

From Dev

Remove a file from git which is not pushed yet but also not in latest commit?

From Dev

Git Move Not-Pushed Commit from temp to master branch

From Dev

Getting rid of an unwanted pushed commit from git log

From Dev

How to change commit message after pushed to remote in Git

From Java

How to retrieve the hash for the current commit in Git?

From Java

How to un-commit last un-pushed git commit without losing the changes

From Java

How do I add a co-author to latest pushed git commit?

From Dev

git filter-branch --msg-filter to reword a pushed commit message

From Dev

Is it possible to squash two pushed commits from the same branch into a single commit with git?

From Dev

Git - accidentally committed and pushed thousands of images - how to I push without that commit?

From Dev

How can I make a single commit of specific branch from other pushed commits in Git?

From Dev

How can I undo last local (not pushed) commit using git-plus?

From Dev

Git repo hosted on Bitbucket.. Count each day where I pushed a commit

From Dev

How to retrieve Git commit id and message in VSTS/TFS build?

From Dev

Accidentally commit pushed to an unknown place

From Dev

Accidentally commit pushed to an unknown place

From Dev

SourceTree - Delete a pushed and merged commit

Related Related

  1. 1

    Check who pushed a Git commit

  2. 2

    change a git commit already pushed

  3. 3

    Check who pushed a Git commit

  4. 4

    When a commit was pushed into a remote Git Repo

  5. 5

    Change name in already pushed commit in Git

  6. 6

    Change the author of last commit in Git(pushed remotely)

  7. 7

    Deleting a local Git Branch that was never pushed - delete it on the server, too?

  8. 8

    Undo a particular commit in Git that's been pushed to remote repos

  9. 9

    git: What is the "right way" to fix an incorrect pushed commit message

  10. 10

    Which git hook to use for validating pushed commit messages?

  11. 11

    how to remove a file from a git commit that has been pushed

  12. 12

    Git forgot to add file change to a not yet pushed commit (not the last one)

  13. 13

    Remove a file from git which is not pushed yet but also not in latest commit?

  14. 14

    Git Move Not-Pushed Commit from temp to master branch

  15. 15

    Getting rid of an unwanted pushed commit from git log

  16. 16

    How to change commit message after pushed to remote in Git

  17. 17

    How to retrieve the hash for the current commit in Git?

  18. 18

    How to un-commit last un-pushed git commit without losing the changes

  19. 19

    How do I add a co-author to latest pushed git commit?

  20. 20

    git filter-branch --msg-filter to reword a pushed commit message

  21. 21

    Is it possible to squash two pushed commits from the same branch into a single commit with git?

  22. 22

    Git - accidentally committed and pushed thousands of images - how to I push without that commit?

  23. 23

    How can I make a single commit of specific branch from other pushed commits in Git?

  24. 24

    How can I undo last local (not pushed) commit using git-plus?

  25. 25

    Git repo hosted on Bitbucket.. Count each day where I pushed a commit

  26. 26

    How to retrieve Git commit id and message in VSTS/TFS build?

  27. 27

    Accidentally commit pushed to an unknown place

  28. 28

    Accidentally commit pushed to an unknown place

  29. 29

    SourceTree - Delete a pushed and merged commit

HotTag

Archive