使用 xcode,如何区分文件的工作副本和存储库中的最新提交?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10666312/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using xcode, how can I diff between a working copy of a file and the latest commit in the respository?
提问by lp1756
Using xcode I would like to see a diff between a working copy of a file and the latest commit in the respository. I know that if I commit I can get the comparison. And I know I do it from the command line using 'git diff'. But is there a way to do it from the xcode GUI?
使用 xcode,我想查看文件的工作副本与存储库中的最新提交之间的差异。我知道如果我承诺,我可以获得比较。而且我知道我使用“git diff”从命令行执行此操作。但是有没有办法从 xcode GUI 中做到这一点?
I keep thinking there must be a way to do this, but can't find it.
我一直在想一定有办法做到这一点,但找不到。
回答by Donn Lee
Here are screenshots.
这是屏幕截图。
Click the Version Editor button in the top-right (highlighted box):
单击右上角的版本编辑器按钮(突出显示的框):
Then, click the revision to compare with (footer highlighted box):
然后,单击要与之比较的修订(页脚突出显示框):
Also, you can navigate through each change using these buttons: <
and >
此外,您可以使用以下按钮浏览每个更改:<
和>
Finally, you can undo a single change with "Discard Change" like so:
最后,您可以使用“放弃更改”撤消单个更改,如下所示:
回答by Phillip Mills
It's not exactly diff but you can get a side-by-side comparison using the version editor button, just above the word "Editor" at the top-right of your Xcode window.
它并不完全不同,但您可以使用版本编辑器按钮进行并排比较,该按钮位于 Xcode 窗口右上角的“编辑器”一词上方。
It's the arrow icon to the right of the Assistant Editor icon on upper right of screen 1. The commit/cancel answer also works. Menu: source_control --> Commit (then cancel).
它是屏幕1右上角的 Assistant Editor 图标右侧的箭头图标。提交/取消答案也有效。菜单:source_control --> 提交(然后取消)。
回答by biomiker
Phillip and Donn both have the correct answer but I'm including an additional screenshot to clarify why using the "Show the Version editor" button is the PRECISELY CORRECT ANSWER TO THIS QUESTION. I'd argue that this should be the accepted answer and all others should be deleted to avoid confusion. :)
Phillip 和 Donn 都有正确的答案,但我还附上了一张额外的屏幕截图来说明为什么使用“显示版本编辑器”按钮是对这个问题的准确答案。我认为这应该是公认的答案,并且应该删除所有其他答案以避免混淆。:)
As shown in the screenshow below, "Show the Version editor" presents a split view that is a VISUAL DIFF between selected revisions, which default to your local revision on the left and the most recent repo revision on the right. The key is to use the arrows centered at the bottom to browse through the individual diffs. The numbers between the arrows indicate the current diff and the total number of diffs.
如下面的屏幕显示所示,“显示版本编辑器”显示了一个拆分视图,它是所选修订版之间的视觉差异,默认为左侧的本地修订版和右侧的最新存储库修订版。关键是使用底部居中的箭头浏览各个差异。箭头之间的数字表示当前差异和差异总数。
回答by Honey
If you purely want to see the difference with the previouscommit then you could just follow the shortcuts for Commitie do: OptCmdC. I find this faster to access. Additionally you will see ALL changes you made and not be limited to a single file.
如果您纯粹想看看与之前提交的区别,那么您可以按照Commit的快捷方式操作,即 do: OptCmdC。我发现这个访问速度更快。此外,您将看到您所做的所有更改,而不仅限于单个文件。
If you want to compare with 2-3 commits before then you would have to use the comparison button that other answers have already mentioned.
如果您想与之前的 2-3 次提交进行比较,则必须使用其他答案已经提到的比较按钮。
EDIT:
编辑:
Xcode10 has a change bar. See this moment from WWDC 2018 Source Control Workflows in Xcode
Xcode10 有一个更改栏。从 Xcode 中的 WWDC 2018 源代码控制工作流中看到这一刻
回答by lp1756
I have discovered a way to do what I want to do. If you hit the commit button on the repository page you are presented with the commit view which provides an opportunity to diff the about to be committed versions of each file with the latest commit in the current branch. You can review your diffs and then cancel the commit.
我发现了一种方法来做我想做的事。如果您点击存储库页面上的提交按钮,您将看到提交视图,该视图提供了一个机会,将每个文件的即将提交版本与当前分支中的最新提交进行比较。您可以查看您的差异,然后取消提交。