问题描述
实际上,我想导出对 github 项目所做的更改,以便将来查看它们。我不想提交他们。现在我愿意
git diff >> change1.txt
然后修改我的更改并再次运行命令
git diff >> change2.txt
这里的问题是我无法在漂亮的彩色预览中查看更改,例如 VS Code 或“git diff”可以显示给我。一种方法是将终端的彩色视图转换为 html 视图,但在这种情况下,很难处理来自 html 代码的真实代码。
解决方法
您可以查看 git stash
:“存储但不在分支中”更改的一种方法是运行:
git stash && git stash apply
# if you want to add a more excpliicit message to your stash :
git stash push -m "my message"
git stash apply
稍后,您可以运行 git stash list
来查看您的收藏夹中的项目列表,并将您的本地更改与您的收藏夹之一进行比较:
git diff stash # to compare your changes to your latest stash
git diff stash@{0} # exact equivalent of the above
git diff stash@{5} # to compare with an older stash listed in 'git stash list'