推送远程仓库导致本地提交记录消失,如何找回

1 天前
HaibaraDP  HaibaraDP

代码提交到了本地仓库,使用 github desktop 的 add local repository 添加本地仓库,点击 pulish repository ,设置仓库名以及可见性都没问题,但推送代码发现无法点击,发现分支可以切换(但我本地只有一个分支),切换后推送上去了,此时再打开 vscode ,就发现本地仓库最近一周的提交记录都没了,github 上也没有,怎么找回呢?

736 次点击
所在节点   git  git
5 条回复
HaibaraDP
HaibaraDP
1 天前
2025-03-17T14:56:56.606Z - info: [main] Using toast activator CLSID {27D44D0C-A542-5B90-BCDB-AC3126048BA2}
2025-03-17T14:56:57.124Z - info: [ui] [AppStore] loading 14 repositories from store
2025-03-17T14:56:57.125Z - info: [ui] [AppStore] found account: mygithubname (mygithubname)
2025-03-17T14:56:57.969Z - info: [ui] [AppStore] removing account mygithubname (mygithubname) from store
2025-03-17T14:56:57.969Z - warn: [ui] fetchAll: 'repos/mygithubname/y/issues?state=open' returned a 401
2025-03-17T14:56:57.975Z - warn: [ui] Alive web socket request failed: Error: Bad credentials
2025-03-17T14:56:58.396Z - error: [ui] Could not get Alive web socket URL for 'mygithubname'
Error: Bad credentials
at cn (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\http.ts:178:11)
at Xn.getAliveWebSocketURL (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\api.ts:848:16)
at Object.createSessionForAccount (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\stores\alive-store.ts:170:7)
at Object.subscribeToAccount (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\stores\alive-store.ts:227:11)
at Object._subscribeToAccounts (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\stores\alive-store.ts:146:37)
2025-03-17T14:56:58.396Z - info: [ui] [fetchProtectedBranches] unable to list protected branches
Error: Bad credentials
at cn (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\http.ts:178:11)
at Xn.fetchProtectedBranches (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\api.ts:1619:7)
at Za.updateBranchProtectionsFromAPI (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\stores\app-store.ts:4123:11)
2025-03-17T14:56:58.397Z - warn: [ui] fetchMentionables: failed for mygithubname/s
Error: Bad credentials
at cn (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\http.ts:178:11)
at Xn.fetchMentionables (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\api.ts:1824:16)
at mN.constructor.updateMentionables (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\stores\github-user-store.ts:90:11)
2025-03-17T14:56:58.607Z - info: [ui] launching: 3.3.6 (Windows 10.0.26100)
2025-03-17T14:56:58.616Z - info: [ui] execPath: 'C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\GitHubDesktop.exe'
2025-03-17T14:56:59.213Z - info: [ui] Executing getRemotes: git remote -v (took 1.093s)
2025-03-17T14:56:59.214Z - info: [ui] Executing getRemotes: git remote -v (took 1.833s)
2025-03-17T14:56:59.234Z - warn: [ui] Alive channel request failed: Error: Bad credentials
2025-03-17T14:57:00.352Z - warn: [ui] Alive web socket request failed: Error: Bad credentials
2025-03-17T14:57:00.352Z - error: [ui] Could not get Alive web socket URL for 'mygithubname'
Error: Bad credentials
at cn (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\http.ts:178:11)
at Xn.getAliveWebSocketURL (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\api.ts:848:16)
at Object.createSessionForAccount (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\stores\alive-store.ts:170:7)
at Object.subscribeToAccount (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\stores\alive-store.ts:227:11)
at Object._subscribeToAccounts (C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\webpack:\app\src\lib\stores\alive-store.ts:146:37)
2025-03-17T14:57:00.352Z - info: [ui] Stats reported.
2025-03-17T14:57:00.732Z - info: [ui] Executing installGlobalLFSFilter: git lfs install --skip-repo (took 2.151s)
2025-03-17T14:57:00.743Z - warn: [ui] Alive channel request failed: Error: Bad credentials
2025-03-17T14:57:02.157Z - info: [ui] Executing fetch: git -c credential.helper= fetch --progress --prune --recurse-submodules=on-demand origin (took 2.824s)
2025-03-17T14:57:03.739Z - info: [ui] Executing updateRemoteHEAD: git -c credential.helper= remote set-head -a origin (took 1.581s)
2025-03-17T14:57:05.935Z - info: [ui] [SignInStore] initializing OAuth flow
2025-03-17T14:57:05.936Z - info: [main] opening in browser: https://github.com/login/oauth/authorize?0
2025-03-17T14:57:39.593Z - info: [main] Received possible protocol arguments: 4
2025-03-17T14:57:39.595Z - info: [main] Processing protocol url
2025-03-17T14:57:39.597Z - info: [ui] [Dispatcher] requesting authenticated user
2025-03-17T14:57:39.707Z - info: [main] Received possible protocol arguments: 3
2025-03-17T14:57:41.091Z - info: [ui] Executing getSymbolicRef: git symbolic-ref -q refs/remotes/origin/HEAD (took 40.737s)
2025-03-17T14:57:42.148Z - info: [ui] [SignInStore] account resolved
2025-03-17T14:57:42.148Z - info: [ui] [AppStore] adding account mygithubname (mygithubname) to store
2025-03-17T14:57:43.060Z - info: [ui] Subscribed 'mygithubname' to Alive channel
2025-03-17T14:58:07.087Z - info: [ui] [AppStore.withAuthenticatingUser] account found for repository: r - mygithubname (has token)
2025-03-17T14:58:07.166Z - info: [ui] [AppStore] adding repository at D:\Code\not_found_product to store
2025-03-17T14:58:08.688Z - info: [ui] Executing isUsingLFS: git lfs track (took 1.256s)
2025-03-17T14:58:09.447Z - info: [ui] Executing fetch: git -c credential.helper= fetch --progress --prune --recurse-submodules=on-demand origin (took 2.357s)
2025-03-17T14:58:10.921Z - info: [ui] Executing updateRemoteHEAD: git -c credential.helper= remote set-head -a origin (took 1.472s)
2025-03-17T14:58:13.400Z - info: [ui] [AppStore.withAuthenticatingUser] account found for repository: l - mygithubname (has token)
2025-03-17T14:58:16.837Z - info: [ui] Executing fetch: git -c credential.helper= fetch --progress --prune --recurse-submodules=on-demand origin (took 3.431s)
2025-03-17T14:58:18.257Z - info: [ui] Executing updateRemoteHEAD: git -c credential.helper= remote set-head -a origin (took 1.419s)
2025-03-17T14:58:19.981Z - info: [ui] [AppStore.withAuthenticatingUser] account found for repository: j - mygithubname (has token)
2025-03-17T14:58:23.191Z - info: [ui] Executing fetch: git -c credential.helper= fetch --progress --prune --recurse-submodules=on-demand origin (took 3.206s)
2025-03-17T14:58:27.755Z - info: [ui] Executing updateRemoteHEAD: git -c credential.helper= remote set-head -a origin (took 4.559s)
2025-03-17T14:58:33.514Z - info: [ui] [AppStore.withAuthenticatingUser] account found for repository:s - mygithubname (has token)
2025-03-17T14:58:55.046Z - info: [ui] Executing fetch: git -c credential.helper= fetch --progress --prune --recurse-submodules=on-demand origin (took 21.527s)
2025-03-17T14:58:56.835Z - info: [ui] Executing updateRemoteHEAD: git -c credential.helper= remote set-head -a origin (took 1.783s)
2025-03-17T14:59:20.012Z - info: [ui] [AppStore.withAuthenticatingUser] account found for repository: v - mygithubname (has token)
2025-03-17T14:59:22.401Z - info: [ui] Executing fetch: git -c credential.helper= fetch --progress --prune --recurse-submodules=on-demand origin (took 2.387s)
2025-03-17T14:59:24.005Z - info: [ui] Executing updateRemoteHEAD: git -c credential.helper= remote set-head -a origin (took 1.603s)
2025-03-17T14:59:26.258Z - info: [ui] [AppStore.withAuthenticatingUser] account found for repository: q - mygithubname (has token)
2025-03-17T14:59:40.294Z - info: [ui] Executing fetch: git -c credential.helper= fetch --progress --prune --recurse-submodules=on-demand origin (took 14.031s)
2025-03-17T14:59:42.566Z - info: [ui] Executing updateRemoteHEAD: git -c credential.helper= remote set-head -a origin (took 2.266s)
2025-03-17T14:59:43.979Z - info: [ui] [AppStore.withAuthenticatingUser] account found for repository: c - mygithubname (has token)
2025-03-17T14:59:47.600Z - info: [ui] Executing fetch: git -c credential.helper= fetch --progress --prune --recurse-submodules=on-demand origin (took 3.617s)
2025-03-17T14:59:49.307Z - info: [ui] Executing updateRemoteHEAD: git -c credential.helper= remote set-head -a origin (took 1.706s)
2025-03-17T14:59:52.257Z - info: [ui] [AppStore.withAuthenticatingUser] account found for repository: t - mygithubname (has token)
2025-03-17T14:59:55.351Z - info: [ui] Executing fetch: git -c credential.helper= fetch --progress --prune --recurse-submodules=on-demand origin (took 3.090s)
2025-03-17T14:59:56.893Z - info: [ui] Executing updateRemoteHEAD: git -c credential.helper= remote set-head -a origin (took 1.541s)
2025-03-17T14:59:57.094Z - info: [ui] [RepositoryIndicatorUpdater]: Refreshing sidebar indicators for 14 repositories took 91.4s of which 21.3s paused, total 112.7s
2025-03-17T15:00:45.248Z - info: [ui] [AppStore.withAuthenticatingUser] account found for repository: not_found_product - mygithubname (has token)
2025-03-17T15:00:48.208Z - info: [ui] [Timing] Action 'checkout branch from list' for 'mygithubname/not_found_product' took 2.960s
2025-03-17T15:00:54.653Z - info: [ui] [AppStore.withAuthenticatingUser] account found for repository: not_found_product - mygithubname (has token)
2025-03-17T15:01:00.699Z - info: [ui] Executing push: git -c credential.helper= push origin master --set-upstream --progress (took 6.025s)
2025-03-17T15:01:03.029Z - info: [ui] Executing fetch: git -c credential.helper= fetch --progress --prune --recurse-submodules=on-demand origin (took 2.327s)
2025-03-17T15:01:04.956Z - info: [ui] Executing updateRemoteHEAD: git -c credential.helper= remote set-head -a origin (took 1.926s)
2025-03-17T15:01:16.206Z - info: [ui] [AppStore.withAuthenticatingUser] account found for repository: not_found_product - mygithubname (has token)
HaibaraDP
HaibaraDP
1 天前
2025-03-17T15:01:18.755Z - info: [ui] Executing fetch: git -c credential.helper= fetch --progress --prune --recurse-submodules=on-demand origin (took 2.539s)
2025-03-17T15:01:20.720Z - info: [ui] Executing updateRemoteHEAD: git -c credential.helper= remote set-head -a origin (took 1.964s)
2025-03-17T15:04:34.078Z - info: [main] Using toast activator CLSID {}
2025-03-17T15:04:34.540Z - info: [ui] [AppStore] loading 15 repositories from store
2025-03-17T15:04:34.541Z - info: [ui] [AppStore] found account: mygithubname (mygithubname)
2025-03-17T15:04:34.554Z - info: [ui] [BranchPruner] Last prune took place 5 minutes ago - skipping
2025-03-17T15:04:35.074Z - info: [ui] launching: 3.3.6 (Windows 10.0.26100)
2025-03-17T15:04:35.075Z - info: [ui] execPath: 'C:\Users\mywindowsname\AppData\Local\GitHubDesktop\app-3.3.6\GitHubDesktop.exe'
2025-03-17T15:04:35.673Z - info: [ui] Subscribed 'mygithubname' to Alive channel
2025-03-17T15:07:31.876Z - info: [ui] [Timing] Action 'checkout branch from list' for 'mygithubname/not_found_product' took 0.000s
2025-03-17T15:11:17.909Z - info: [ui] [RepositoryIndicatorUpdater]: Refreshing sidebar indicators for 14 repositories took 17.3s of which 216.9s paused, total 234.2s
2025-03-17T15:19:35.193Z - info: [ui] [AppStore] adding repository at D:\Code\ad to store
2025-03-17T15:19:36.599Z - info: [ui] Executing isUsingLFS: git lfs track (took 1.162s)
2025-03-17T15:22:37.670Z - info: [ui] Executing push: git -c credential.helper= push origin main --set-upstream --progress (took 2.933s)
2025-03-17T15:22:39.760Z - info: [ui] Executing fetch: git -c credential.helper= fetch --progress --prune --recurse-submodules=on-demand origin (took 2.084s)
2025-03-17T15:22:41.708Z - info: [ui] Executing updateRemoteHEAD: git -c credential.helper= remote set-head -a origin (took 1.942s)
2025-03-17T15:40:24.559Z - info: [ui] [RepositoryIndicatorUpdater]: Refreshing sidebar indicators for 15 repositories took 14.5s of which 1041.6s paused, total 1056.1s
2025-03-17T15:43:18.225Z - info: [ui] [RepositoryIndicatorUpdater]: Refreshing sidebar indicators for 15 repositories took 14.0s of which 0.0s paused, total 14.0s

上面是 github desktop 的日志
HaibaraDP
1 天前
感谢 grok3 ,通过 git reflog --date=iso 找到了
prosgtsr
21 小时 27 分钟前
我唯一一条记住的命令就是 git reflog 。。。其他操作全用 idea
hexiaowu1993
19 小时 33 分钟前
本地只要 commit 过,都可以通过 git reflog 找回来

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1119177

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX