0

After doing a "git fetch origin" to pull in a remote branch added my a colleague, I did "git checkout .

This output: Branch set up to track remote branch from origin. Switched to a new branch ""

I have a post-merge script to run SQL scripts merged into my local repository. HOWEVER, when I ran my git checkout , I pulled in some SQL files and my script did not run, meaninng no merge was done.

How does it get the remote branch onto the local branch if it isn't merging?

Thanks in advance!

ericleit
  • 311
  • 3
  • 11

1 Answers1

0

A git fetch does not merge. It does not update your working copy. A merge is automatic when you do a git pull.

So creating a new remote-tracking branch by fetching does not actually merge anything into your working tree, you must decide what to do now.

A git merge origin/master will merge in the remote origin server branch of master to your working directory.

If you want to merge directly to your working tree use git-pull, from the man page:

More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. With --rebase, it runs git rebase instead of git merge.

Michael
  • 10,124
  • 1
  • 34
  • 49
  • Thanks Michael! I understand that difference. My question is how does checkout on a remote branch copy over the remote's data onto my local machine without running a merge? – ericleit Jul 29 '13 at 14:02
  • When you checkout you are changing your working copy, you are not merging, I think you are getting the concepts confused, if you have no changes in your current working copy and checkout a new one, the working copies are switched, since nothing is in a changed status, this seems like magic and your files are changed, but you are just in a new branch. – Michael Jul 29 '13 at 17:35
  • You have your working directory and your .git directory - when you fetch you update your .git directory with references and information about branches, tags, files and history - this does not affect your working directory until you merge some history to your working directory. If you working directory is in a stable state (all committed), you can checkout without having to do anything and it will seem like you are changing your current branch, but really you are just swapping your current directory for a new working directory. – Michael Jul 31 '13 at 01:23