在我提交之前,我使用 git ..
(我在子目录中)进行了所有更改的暂存,并运行了 git status 以查看已暂存的更改。此时,Git仅暂存了更改的文件,就像预期的一样。
在命令行中,我运行 git commit
并写上一条消息,得到以下响应:
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
[SelectingDate 910641c4] Switching from many visibility animators to one translate animated view. Cuts down time to update list significantly.
7 files changed, 43 insertions(+), 15 deletions(-)
rename mobile/features/itemLists/CursorItemsCoordinator/{AnimatedVisibilityCursor.native.js => AnimatedTranslatingCursor.native.js} (52%)
虽然我不太习惯看到“自动打包”消息,但我已经找到了其他文章可以帮助我摆脱它。然而,根据他的Cl响应,更改似乎已经提交。
接着我立即运行git status
,令我惊讶的是,这是响应:
On branch SelectingDate
No commits yet
然后它列出了我仓库中所有文件都已经添加至缓存区。
我的仓库中的文件似乎已更新到它们当前的版本,这很好。有人知道可能是什么导致删除了我当前分支上的所有提交/如何将它们恢复(如果可能的话)吗?
以下是完整的命令行交互:
➜ mobile git:(SelectingDate) ✗ gs
On branch SelectingDate
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: features/itemLists/CursorItemsCoordinator/AnimatedVisibilityCursor.native.js
modified: features/itemLists/CursorItemsCoordinator/CursorItemsCoordinator.native.js
modified: features/itemLists/CursorItemsCoordinator/interpolaters.native.js
modified: features/itemLists/MainListView/MainItemsList.native.js
modified: helpers/animatedIndexHelper.native.js
modified: ../shared/itemLists/listTypes/plan/PlanItemsContainer.shared.js
modified: ../web/src/__test__/native/interpolaters.test.js
Untracked files:
(use "git add <file>..." to include in what will be committed)
features/itemLists/CursorItemsCoordinator/AnimatedTranslatingCursor.native.js
no changes added to commit (use "git add" and/or "git commit -a")
➜ mobile git:(SelectingDate) ✗ git add ..
➜ mobile git:(SelectingDate) ✗ gs
On branch SelectingDate
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
renamed: features/itemLists/CursorItemsCoordinator/AnimatedVisibilityCursor.native.js -> features/itemLists/CursorItemsCoordinator/AnimatedTranslatingCursor.native.js
modified: features/itemLists/CursorItemsCoordinator/CursorItemsCoordinator.native.js
modified: features/itemLists/CursorItemsCoordinator/interpolaters.native.js
modified: features/itemLists/MainListView/MainItemsList.native.js
modified: helpers/animatedIndexHelper.native.js
modified: ../shared/itemLists/listTypes/plan/PlanItemsContainer.shared.js
modified: ../web/src/__test__/native/interpolaters.test.js
➜ mobile git:(SelectingDate) ✗ gc "Switching from many visibility animators to one translate animated view. Cuts down time to update list significantly."
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
[SelectingDate 910641c4] Switching from many visibility animators to one translate animated view. Cuts down time to update list significantly.
7 files changed, 43 insertions(+), 15 deletions(-)
rename mobile/features/itemLists/CursorItemsCoordinator/{AnimatedVisibilityCursor.native.js => AnimatedTranslatingCursor.native.js} (52%)
➜ mobile git:(SelectingDate) ✗ gs
On branch SelectingDate
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: ../.gitignore
new file: ../.prettierignore
new file: ../.yarn/install-state.gz
new file: ../README.md
new file: .eslintrc.json
new file: .expo-shared/assets.json
new file: .prettierrc.json
new file: App.native.js
new file: app.json
new file: assets/adaptive-icon.png
new file: assets/favicon.png
new file: assets/fonts/MavenProLight-200.otf
new file: assets/fonts/MavenProLight-300.otf
new file: assets/fonts/MavenProMedium.otf
new file: assets/fonts/maven_pro_bold-webfont.ttf
new file: assets/fonts/maven_pro_regular-webfont.ttf
new file: assets/icon.png
new file: assets/splash.png
new file: babel.config.js
new file: constants/colors.js
... (and all the rest of the files in my repository)
在项目根目录中仍存在 .git 目录,且大小超过 100MB。
Git 版本 2.24.3 (Apple Git-128)
运行 git reflog --all
命令的结果。
910641c4 (selectingDate) refs/heads/selectingDate@{0}: commit: Switching from many visibility animators to one translate animated view. Cuts down time to update list significantly.
f367a4d0 (refs/stash) refs/stash@{0}: WIP on SelectingDate: 37d06850 Ensures that restoreListener is readded to animatedDateValue when it is updated (and that any old one is removed).
e1437645 refs/stash@{1}: WIP on master: 193f904e Merge pull request #213 from bendelonlee/MobileGraphicCalNotes
f16f4e59 refs/stash@{2}: WIP on selectingDate: 37d06850 Ensures that restoreListener is readded to animatedDateValue when it is updated (and that any old one is removed).
37d06850 refs/heads/selectingDate@{1}: commit: Ensures that restoreListener is readded to animatedDateValue when it is updated (and that any old one is removed).
...
gs
和gc
别名究竟是什么? - Schwern.git/logs/refs/heads/SelectingDate
存在吗?如果存在,最后几行是什么?您还可以尝试git reflog --all
和git log --graph --decorate --reflog --all
来查找丢失的提交。 - Schwern