英文:
How to compare current workingspace with previous commit in git?
问题
有时候我在修复错误时,需要将当前存储库与特定提交进行比较,以查看哪些文件正在更改以及整体功能。
在VSCode中使用Git History扩展,我只能一次比较一个文件与特定提交,但我想查看整个存储库的更改。目前,我会执行软重置到我想要比较的提交。
git reset --soft 13dbd96
在Git或第三方VSCode扩展中是否有其他更高效的使用方法?
英文:
Sometimes when I fix bugs, I need to compare current repo with a specific commit to see which files are being changed and overall features.
Using git history extension in vscode, I can only compare one file at a time with a specific commit but I want to view the entire repo changes. Currently, I soft reset to the commit I want to compare.
git reset --soft 13dbd96
Is there other ways in git or third party vscode extensions to use that is more efficient?
答案1
得分: 0
使用git diff
命令进行比较。正如@evolutionxbox所建议的,你可以使用git diff 13dbd96
来查看示例。你还可以通过查看不同blob的路径来进行导航。
例如,你可以使用命令git diff HEAD~2
来查看当前版本与HEAD~2
版本之间的所有差异。
另一件事情:在多次更改HEAD的位置之前,git reset
可以是查看版本之间文件变化列表的一个明智方式,但在改变HEAD位置之前,你可能希望确保已经储藏了你的更改。你不想意外执行硬重置然后丢失你最近的更改。
英文:
Use the git diff
command to compare. As @evolutionxbox suggested, you could use git diff 13dbd96
for your example. You can also make use of navigations by looking at the paths to your different blobs.
For instance, you can see all differences between your current version and the version at HEAD~2
by using the command, git diff HEAD~2
.
Another thing: git reset
can be a smart way to look at lists of files that changed between versions, but you'll probably want to make sure you have stashed your changes before changing the position of the HEAD a bunch of times. You don't want to accidentally do a hard reset and then lose your most recent changes.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论