如何在 Xcode 中查看 Git 将推送到服务器的文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16565540/
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
How can I see what files Git is going to push to the server in Xcode?
提问by lehn0058
I have Git setup on an Xcode project and I make many small local commits before I push them to the server. However, I am not able to tell easily what all of the file changes are if I would do a git push. I know that you can look in the organizer and see all of your individual commits, but I can't seem to find an aggregate view of these changes.
我在 Xcode 项目上设置了 Git,在将它们推送到服务器之前,我做了许多小的本地提交。但是,如果我执行 git push,我无法轻松判断所有文件更改是什么。我知道您可以查看组织者并查看您的所有个人提交,但我似乎无法找到这些更改的汇总视图。
Essentially, if I commit changes locally to a file multiple times, I want to see the aggregate of those changes before I push the file to the server.
本质上,如果我多次在本地提交对文件的更改,我希望在将文件推送到服务器之前查看这些更改的汇总。
Does something like this exist in Xcode, or in some 3rd party tools for Xcode?
Xcode 或 Xcode 的某些 3rd 方工具中是否存在这样的东西?
回答by GayleDDS
Command Line
命令行
git diff --name-only origin/master
Will list the files that you have changed but not pushed.
将列出您已更改但未推送的文件。
git diff origin/master directory_foo/file_bar.m
Will list the line by line diff of all the un-pushed changes to directory_foo/file_bar.m.
将逐行列出对 directory_foo/file_bar.m 的所有未推送更改的差异。
GUI Tool
图形用户界面工具
If your looking for GUI Tools for a Git workflow, I use Xcode to commit locally and SourceTree to push and pull. Before Xcode and SourceTree I was a diehard command line SCM person. But I really like committing locally with Xcode, it streamlined a multi-step process of reviewing the change diffs and committing very nicely. The more I've used SourceTree the more I like it and the less I use the command line. I've always liked Atlassian's products and the $10 license for indies and small startups rocks. Now I just Love them to death for buying SourceTree and making free on the Mac App Store.
如果您正在寻找用于 Git 工作流程的 GUI 工具,我使用 Xcode 在本地提交并使用 SourceTree 进行推送和拉取。在 Xcode 和 SourceTree 之前,我是一个死忠的命令行 SCM 人。但我真的很喜欢使用 Xcode 在本地提交,它简化了更改差异和提交非常好的多步骤过程。我使用 SourceTree 的次数越多,我就越喜欢它,而我越少使用命令行。我一直很喜欢 Atlassian 的产品和 10 美元的独立开发者和小型初创公司的许可证。现在我简直爱死他们了,因为他们购买了 SourceTree 并在 Mac App Store 上免费。
I think SourceTree does exactly what you want to do. On the tool bar the red 3 shows I have 3 commits to push. You just select master and origin/master to get an aggregate of what will be pushed. The bottom left pain shows the files changed and the right shows the aggregated diff for that file.
我认为 SourceTree 正是您想要做的。在工具栏上,红色 3 显示我有 3 个要推送的提交。您只需选择 master 和 origin/master 即可获得将要推送的内容的汇总。左下角疼痛显示文件已更改,右侧显示该文件的汇总差异。
FYI: Two awesome presentations on Git (Absolutely Must Watch)
仅供参考:关于 Git 的两个精彩演示(绝对必须观看)
Git For Ages 4 And Up http://www.youtube.com/watch?v=1ffBJ4sVUb4
Git 4 岁及以上 http://www.youtube.com/watch?v=1ffBJ4sVUb4
Advanced Git http://vimeo.com/49444883
高级 Git http://vimeo.com/49444883
回答by rubenjohne
You can tell the changes of your local repository vs your remote repository from the Terminal in your local repository directory by using the command
您可以使用命令从本地存储库目录中的终端告诉本地存储库与远程存储库的更改
git diff [local] [remote]
for example:
例如:
git diff master origin/master
回答by Dherik
Use git show
to retrieve the commits you made.
使用git show
检索所做的提交。
Get the SHA identification of your commits and:
获取提交的 SHA 标识,并且:
git diff 0da94be..59ff30c
Another option is:
另一种选择是:
git diff origin/master
The command above show the diff of the files to be pushed
上面的命令显示了要推送的文件的差异