2

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.

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. How does this work with Xcode?

For example, on one machine on Branch1, I put in some changes.

Then on machine 2, on Branch2, I want to fetch Branch1 changes.

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. 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.

Crystal
  • 28,460
  • 62
  • 219
  • 393

3 Answers3

2

I thought git fetch grabs the code but does not merge it yet like git pull does.

Yes, that is correct. git merge is what updates your working directory, which is why...

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. That's what git merge does. Remember that git pull is basically a git fetch followed by a git merge.

Matt Ball
  • 354,903
  • 100
  • 647
  • 710
0

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.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
0

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.

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

Kaptain
  • 1,358
  • 12
  • 20