1

I've done a 'git --reset hard origin/master' on a local branch so I'm expecting my local branch to match exactly to the remote one. However when I do a:

git log --graph --oneline --decorate --all

I get the following output at the top:

*   dfd9bc6 (refs/stash) On z_tmp2: tmp1
|\  
| * 49f3b6f index on z_tmp2: 84e2002 localconfig
|/  
* 84e2002 localconfig
| * 1110f48 (origin/congo-3.1-stable) Boiler plate code to support

Commits 84e2002, 49f3b6f and dfd9bc6 appear to be local work which I though would've been wiped out by the 'reset --hard', but apparently I'm missing something.

4

1 回答 1

1

reset不会清除任何东西,它只是将分支重置为不同的提交。

正如您在日志输出中看到的那样,您仍然有一个 ref ( refs/stash,您的默认stash ) 指向您的旧提交。

如果您不再需要这些提交并想让它们从日志中消失,请使用

git stash drop

一旦不再引用提交,Git 垃圾收集器的下一次运行就会从 Git 对象存储中实际删除提交。但除非您有磁盘空间问题,否则您可能不必担心。

于 2013-04-30T19:23:10.593 回答