我正在我的分支机构工作,我忘记了我的更改。然后我切换到主分支并从回购中提取更改。之后我回到我的分支机构并合并了master的更改。 我尝试了一些方法来撤消更改,例如this site,但没有任何效果。
这是我跑的命令:
(on branch new)
git add -A
git checkout master
git pull
git checkout new
git merge master
所以我在添加所有文件后忘了提交,现在我的所有更改都丢失了。有没有办法把它带回来?
git reflog
给了我:
1b131cc HEAD@{1}: checkout: moving from new to new
1b131cc HEAD@{2}: merge master: Merge made by the 'recursive' strategy.
1b68f12 HEAD@{3}: checkout: moving from master to new
481a3d8 HEAD@{4}: pull: Fast-forward
d036eda HEAD@{5}: checkout: moving from new to master
git fsck --lost-found
给了我:
Checking object directories: 100% (256/256), done.
Checking objects: 100% (7099/7099), done.
dangling blob 318983dc9be70b96795f20ddc30da34506a90686
dangling blob fb92b205dbeeeb507b57dac1ef71676cda81393f
dangling blob 459e993441c9d87620a16acf13ea775fbf2995d2
dangling blob 2927b0f2104b6cf81e70cac33059ca3170555347
dangling blob d82971111c7b858e3ae9444d1f63ac9dfb864c49
dangling commit 65b0e95ec2b07837b921d032f7233abbe58e67eb
dangling commit 8f31e7b43d82894e825d73b3e57c2a1cd93b9ec2
dangling commit f5b13ac3cad384c6752081a82114647f879083df
dangling blob 3dccfdeee2d715045a8063cf92f89c0c70dbb96c
dangling commit 8cd2e7c0d89389dcac3f0cc0644874e06675128f
dangling commit 2fd6e1a36046432173c8aec3f3e50cb4182fdabb
dangling blob b9dc20c047ca16043a3eb6899284b86d4cdcc70b
dangling blob 11deb3d56d8902578f78f2c7477662bac1d378bd
dangling commit ea66df6e6d273360f0401bab69d2f4021daa3d49
dangling commit b16afa88716265f3aa4df1d40bd0a8471a631d51
dangling blob 207440e8625330fd26925f0c15485caea2aa723d
dangling blob b8f7e70d326474263b7910a16a9e18e13efbfafb
dangling blob 93793d9b405aff5117bd91cfe40008c583278756
答案 0 :(得分:0)
我认为你错过了一步。我假设@git add -A你做了一些工作。
(on branch new)
git add -A
git checkout master
此时您会看到以下消息:
error: Your local changes to the following files would be overwritten by checkout:
bla.file
Please, commit your changes or stash them before you can switch branches.
Aborting
在这一步你做了一个git stash,git reset(如果你用--hard这里你丢失了你的工作)或git commit(如果你没有改变你做了git stash,否则你会看到你的应该丢失的变化。)
在这种情况下,有两种方法导致失去工作。
如果您提交了更改,则会在您提交的分支中找到它们。如果你藏匿它们,你会在藏匿列表中找到它。