Github Desktop 2.9.4 -> Auto Rebase Triggered - Commits Lost?

Hi Everyone,

So I’ve a repo with a main & feature branch and I’m working (solo) exclusively in the feature branch.

I’ve been using GHD 2.9.3 and this morning completed a set of changes, most of which were then committed locally (to be pushed to origin at the end of the day)

After committing locally, I noticed a prompt saying 2.9.4 had installed, so re-started to update. After restarting, I was automatically prompted with a dialog referring to a rebase…

Rebase

Now I never triggered this. I always use Squash & Merge into the main branch and never have reason to Rebase. On-top of this, I don’t understand how a conflict can occur in a feature branch that only I work on and is always ahead of main.

After clicking abort, GHD reverted back to a point in July and all changes since then appear lost. Pull origin is showing 198 deltas, which I assume are the commits since July. Which hopefully means they’re still in the local repo, but somehow hidden (the local repo shows no stashed changes)

After speaking to a friend who is far more of expert on GH than myself, he suspects I just need to move the head back to the last commit.

Could it be related to this…

Merge dialog auto closes after conflicts are resolved · Issue #12881 · desktop/desktop (github.com)

Which in-turn references this…

Fix merge head check regression introduced with squash merge by tidy-dev · Pull Request #12923 · desktop/desktop (github.com)

Any help would be greatly appreciated!

Kind regards, David

Quick update…

So I used…

git reflog

And determined that the head was not where it should be. This mornings commits were showing however, so I used the following to move the head to the last known commit…

git checkout [hash]

Then finally…

git reset --hard HEAD

Now on opening Github Desktop my commits are back in the history tab (great!) but the branch is still showing as detached, which I understand it should not be?

On-top of that, if I switch to the feature branch this mornings commits once again disappear.

If you git checkout a commit by its hash Git goes into “detached HEAD” state, where you aren’t on any branch at all. That’s also why your feature branch is unchanged: You didn’t reset that branch, you just checked out a commit and reset your working tree to that state.

The easiest way to fix the branch and get out of detached HEAD state is to check out the branch, and then reset it to the correct commit. Double check there aren’t any changes in the working tree that you want to keep before using git reset --hard. :warning:

git checkout feature-branch
git reset --hard CORRECT_COMMIT_HASH

See: git reset [<mode>] [<commit>]

1 Like

Thank you! @airtower-luna That worked perfectly!

I zipped up the local repo as soon as it happened, so had a fresh copy.

So after unzippping the backup, I did the following…

  1. Discarded two uncommited changes to keep things simple (backing up the files first)
  2. git checkout (branch)
  3. git reset --hard (hash)
  4. Copied back the uncommited files

Et voila! My repo is back in the state it should have been in the first place.

I honestly do not know what happened. The update to 2.9.4 seemed to trigger this and it kept reverting to a state two months ago, but I do not know why. The commit it was reverting to did show something around that time, specifically…

checkout: moving from (commit id) to (feature-branch)


rebase (start) checkout (commit id)
reset: moving to HEAD

I don’t recall ever doing a Rebase, although do have recollections of reverting a change at around that time.

Who knows!

Anyway, thank you again! It’s hugely appreciated :slight_smile:

Kind regards
David

1 Like

:wave: @peachypixels I work on the GitHub Desktop team – would you be willing to share your log file so that I could take a look at what might have happened here?

To access the log files go to the file menu in GitHub Desktop and select Help > Show Logs in Finder (macOS) or Explorer (Windows).

The log files are created daily – please upload a log file as an attachment from a day where you experienced the issue. Thanks!

Hi Steve,

Happy to send the log, but is there a way of sending it privately as it does contain personal info?

Kind regards
David

Hi Steve,

Ok, I’ve copied the relevant portion of the logs (at the bottom) and redacted personal info.

This is what happened…

  1. Opened GHD (2.9.3) to commit (but not push) four changes.
  2. Committed the four changes.
  3. Noticed the upgrade notification, so read the changelog.
  4. Closed GHD which triggered an upgrade to 2.9.4
  5. Upon opening GHD 2.9.4 it triggered the auto-rebase that I posted above (I clicked Abort Rebase)
  6. Close GHD, frowned a little then phoned a friend who knows more about GH than me :slight_smile:

Hopefully this helps, but if not I also have some screenshots of a reflog that might shed some light on things.


Log from point of first opening GHD to realising there was an issue…

2021-10-06T12:53:09.083Z - info: [ui] [AppStore] loading 2 repositories from store
2021-10-06T12:53:09.084Z - info: [ui] [AppStore] found account:
2021-10-06T12:53:10.057Z - info: [ui] launching: 2.9.3 (Windows 10.0.19043)
2021-10-06T12:53:10.057Z - info: [ui] execPath: ‘C:\Users<redacted>\AppData\Local\GitHubDesktop\app-2.9.3\GitHubDesktop.exe’
2021-10-06T12:53:13.490Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 2.997s)
2021-10-06T12:53:13.531Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 3.092s)
2021-10-06T12:53:16.570Z - info: [ui] Executing fetch: git -c credential.helper= -c protocol.version=2 fetch --progress --prune origin (took 1.358s)
2021-10-06T12:53:19.500Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 2.156s)
2021-10-06T12:54:55.233Z - info: [ui] Executing getWorkingDirectoryDiff: git diff --no-ext-diff --patch-with-raw -z --no-color HEAD – <redacted.file> (took 1.239s)
2021-10-06T13:02:26.371Z - info: [ui] [RepositoryIndicatorUpdater]: Refreshing sidebar indicators for 1 repositories took 1.4s of which 0.0s paused, total 1.4s
2021-10-06T13:02:28.549Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 2.819s)
2021-10-06T13:02:47.672Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.625s)
2021-10-06T13:04:12.867Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.665s)
2021-10-06T13:04:13.282Z - info: [ui] [Timing] Action ‘create commit’ for ‘<redacted.branch>’ took 3.004s
2021-10-06T13:04:15.020Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.414s)
2021-10-06T13:05:06.893Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.554s)
2021-10-06T13:05:07.271Z - info: [ui] [Timing] Action ‘create commit’ for ‘<redacted.branch>’ took 2.723s
2021-10-06T13:05:09.031Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.540s)
2021-10-06T13:05:18.362Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.375s)
2021-10-06T13:05:25.432Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.371s)
2021-10-06T13:06:37.859Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.547s)
2021-10-06T13:09:15.074Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.672s)
2021-10-06T13:09:22.162Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.768s)
2021-10-06T13:09:22.581Z - info: [ui] [Timing] Action ‘create commit’ for ‘<redacted.branch>’ took 3.062s
2021-10-06T13:09:24.336Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.512s)
2021-10-06T13:11:01.923Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.668s)
2021-10-06T13:11:23.521Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.699s)
2021-10-06T13:11:24.110Z - info: [ui] [Timing] Action ‘create commit’ for ‘<redacted.branch>’ took 3.270s
2021-10-06T13:11:25.761Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.355s)
2021-10-06T13:11:32.815Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 3.072s)
2021-10-06T13:11:35.806Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.483s)
2021-10-06T13:11:49.925Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.285s)
2021-10-06T13:11:58.240Z - info: [main] opening in browser: Release Notes for GitHub Desktop | GitHub Desktop
2021-10-06T13:14:41.020Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 1.426s)
2021-10-06T13:14:43.000Z - info: [ui] [AppStore] loading 2 repositories from store
2021-10-06T13:14:43.001Z - info: [ui] [AppStore] found account:
2021-10-06T13:14:43.286Z - info: [ui] [BranchPruner] Last prune took place in a day - skipping
2021-10-06T13:14:43.808Z - info: [ui] launching: 2.9.4 (Windows 10.0.19043)
2021-10-06T13:14:43.809Z - info: [ui] execPath: ‘C:\Users<redacted>\AppData\Local\GitHubDesktop\app-2.9.4\GitHubDesktop.exe’
2021-10-06T13:14:45.001Z - info: [ui] Executing installGlobalLFSFilter: git lfs install --skip-repo (took 1.189s)
2021-10-06T13:14:48.095Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 3.973s)
2021-10-06T13:14:48.212Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 3.889s)
2021-10-06T13:14:52.381Z - info: [ui] Executing getBinaryPaths: git diff --numstat -z REBASE_HEAD (took 3.387s)
2021-10-06T13:15:00.064Z - info: [ui] Executing abortRebase: git rebase --abort (took 1.338s)
2021-10-06T13:16:10.874Z - info: [ui] [RepositoryIndicatorUpdater]: Refreshing sidebar indicators for 1 repositories took 0.4s of which 0.0s paused, total 0.4s
2021-10-06T13:16:14.972Z - info: [ui] [BranchPruner] Last prune took place in a day - skipping

1 Like