简体   繁体   English

用Xcode提取git

[英]git fetch with Xcode

I've had problems using git pull origin SomeBranch in that when there are conflicts, sometimes I cannot open a file in Xcode to resolve the conflict. 我在使用git pull origin SomeBranch时遇到问题,因为当发生冲突时,有时我无法在Xcode中打开文件来解决冲突。

From my reading, although I could be wrong, I thought git fetch grabs the code but does not merge it yet like git pull does. 从我的阅读中,虽然我可能是错的,但我认为git fetch可以获取代码,但还不像git pull那样合并。 How does this work with Xcode? Xcode如何运作?

For example, on one machine on Branch1, I put in some changes. 例如,在Branch1的一台计算机上,我进行了一些更改。

Then on machine 2, on Branch2, I want to fetch Branch1 changes. 然后在机器2的Branch2上,我想获取Branch1的更改。

So I did this 所以我做到了

git fetch origin Branch2

My output from the command line was: 我在命令行中的输出是:

*branch      Branch2     -> FETCH_HEAD

What does this mean? 这是什么意思? When I go to the source file of the file that I changed, I do not see any changes made. 当我转到所更改文件的源文件时,看不到任何更改。

I thought what would happen is in Xcode, it would then show the changes of that file in that source file and that file would then be Modified. 我以为Xcode中会发生什么,然后它将在该源文件中显示该文件的更改,然后对该文件进行修改。 And only when I commit would it be added to the staging area so I could merge it with everything else. 而且只有在我提交时,它才会添加到暂存区域,以便我可以将其与其他所有内容合并。 But maybe I am understanding it incorrectly. 但是也许我理解不正确。 Thoughts? 有什么想法吗? Thanks. 谢谢。

I thought git fetch grabs the code but does not merge it yet like git pull does. 我以为git fetch可以抓取代码,但不会像git pull那样合并它。

Yes, that is correct. 对,那是正确的。 git merge is what updates your working directory, which is why... git merge是什么会更新您的工作目录,这就是为什么...

When I go to the source file of the file that I changed, I do not see any changes made. 当我转到所更改文件的源文件时,看不到任何更改。

git fetch retrieves the objects that represent the changes, but does not update your working directory. git fetch检索代表更改的对象, 但不更新您的工作目录。 That's what git merge does. 这就是git merge所做的。 Remember that git pull is basically a git fetch followed by a git merge . 请记住, git pull本质上是git fetch然后是git merge

fetch just updates your remote tracking branch. 提取只会更新您的远程跟踪分支。

This allows you to inspect what was pulled down from the server before integrating those changes with what you have locally. 这使您可以在将这些更改与本地更改集成之前检查从服务器上拉出的内容。

You now either merge or rebase those changes to your local branch (if it exists). 现在,您可以将这些更改合并或重新设置到本地分支(如果存在)。 If it doesn't, you can simply 如果没有,您可以简单地

git checkout branch2

if it does, 如果有,

git merge origin/branch2

or 要么

git rebase origin/branch2

to skip this 2 step process, just 跳过这两步过程,只是

git pull origin branch2

which will by default merge. 默认情况下将合并。 You can override with 您可以使用

git pull --rebase origin branch2

you can change your config so that pull will always rebase instead of merge. 您可以更改配置,以使pull将始终重新设置基准,而不是合并。

For a Git repository, you need to save changes you've made and commit them to your local repository before updating changes from the shared repository. 对于Git存储库,您需要保存所做的更改并将其提交到本地存储库,然后再从共享存储库更新更改。

https://developer.apple.com/library/ios/recipes/xcode_help-source_control_management/UpdatingorPullingChanges/UpdatingorPullingChanges.html https://developer.apple.com/library/ios/recipes/xcode_help-source_control_management/UpdatingorPullingChanges/UpdatingorPullingChanges.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM