j_quelly
j_quelly

Reputation: 1439

lost stash and commit

I commit and stashed some work and now when changing back to the branch and trying to apply the stash I seem to be behind (about two weeks worth of work).

Here is what I did via terminal history:

$ git checkout dashboard-improvements
$ git pull
$ git stash apply "stash@{0}" (all is well at this point)
$ git status (finished working, wanted to see my changes)
$ git stash (received a warning about files not being commit)
$ git add -A && git commit -m "" (received a warning about blank commit message)
$ git add -A && git commit -m "create order" "
"
$ git stash
$ git checkout staging && git pull

At this point I continued to work on some other branches and projects.

I then went back to the dashboard-improvements branch and tried to apply my latest stash, but I am seeing old work:

$ git branch (viewed my branches)
$ git checkout dashboard-improvements
$ git status
$ git stash apply "stash@{0}" (seeing really old work)

I'm kind of panicking and I'm not really sure what to do. I've tried $git fsck --lost-found and there are a ton of dangling commits, but I'm afraid to play around and potentially lose my work.

Is there a way to see the local commit with the sketchy quotations:

    $ git add -A && git commit -m "create order" "
    "

Upvotes: 0

Views: 76

Answers (1)

Schwern
Schwern

Reputation: 164659

Let's pull apart what happened.

$ git checkout dashboard-improvements
$ git pull

Updated dashboard-improvements from the remote.

$ git stash apply "stash@{0}" (all is well at this point)

Applied some work from the last thing you stashed.

$ git status (finished working, wanted to see my changes)

Checked your status.

$ git stash (received a warning about files not being commit)

Stashed the changes you just applied. Why?

$ git add -A && git commit -m ""

Committed nothing, you just stashed all your changes.

$ git stash

Stashed nothing. Why?

$ git branch (viewed my branches)
$ git checkout dashboard-improvements
$ git status
$ git stash apply "stash@{0}" (seeing really old work)

At this point I have no idea what's in your stash.


The issue I see is you seem to be stashing as a cargo-cult thing. Your stash is probably full of all sorts of junk. Run a git stash list -p, look through what's there, and sort out what's useful and what isn't.

You might want to review the Stashing and Cleaning chapter of the Git Book.

Upvotes: 1

Related Questions