如何从 Git 导出所有更改/添加的文件?
我对 Git 很陌生,有一个小问题。
在 SVN 中[这感觉就像阿尔伯特叔叔的《只有傻瓜和马》的故事......“在战争期间......”]当我想用我的最新更改更新生产站点时,我会这样做TSVN 中的差异并导出两个修订版之间所有更改/添加的文件。正如您可以想象的那样,之后很容易将这些文件发送到生产站点。
但是,我似乎无法在 Git 中找到“导出更改的文件”选项。我可以进行比较并查看更改,我可以获得文件列表,但实际上无法导出它们。有没有合理的方法来做到这一点?我错过了一些简单的事情吗?
只是为了再次澄清,我需要导出两个特定提交之间的所有更改。
提前致谢!
I am very new to Git and I have a slight problem.
In SVN [this feels like an Only Fools and Horses story by uncle Albert.."during the war..."] when I wanted to update a production site with my latest changes, I'd do a diff in TSVN and export all the changed/added files between two revisions. As you can imagine, it was easy to get those files to a production site afterwards.
However, it seems like I'm unable to find an "export changed files" option in Git. I can do a diff and see the changes, I can get a list of files, but I can't actually export them. Is there a reasonable way to do this? Am I missing something simple?
Just to clarify once again, I need to export all the changes between two specific commits.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您想如何导出它们?你说你已经有了一份清单;你还想要什么? 来获取列表
假设您正在使用 git diff --name-only ...类似的东西
?或者你甚至可以使用 diff 本身 - 它可以与 git apply 一起应用(我相信甚至可以使用 patch )。
How do you want to export them? You say you already have a list; what more do you want? Supposing you're getting your list with
git diff --name-only ...
Something like that?
Or you could even use the diff itself - it can be applied with
git apply
(or evenpatch
, I believe).借用此处,这是导出在工作区中修改的文件的另一种方法:
如果需要将未跟踪的文件包含在差异中,您可能需要预先执行以下命令来添加它们:
[这适用于 Windows 中的 git-bash]
Borrowing from few of the answers in here, here is another way to export files that are modified in the workspace:
You might need to execute the following beforehand to add untracked files, if you need to include them in the diff:
[This works in git-bash in Windows]