1

So I've read plenty of answers on this already, saying that pull = fetch + merge. But I'm not totally convinced. This morning instead of doing a "git pull" to update my code with everyone's changes, I did "git fetch," and then ran "git merge" which resulted in a bunch of errors. Actually, "git merge" didn't work on its own. I'm on the origin/develop branch, so I did "git merge origin develop" and it gave me several errors (which I didn't save, unfortunately).

So, what is the EXACT syntax I should've used?

CaptSaltyJack
  • 15,283
  • 17
  • 70
  • 99
  • 1
    You may have run into a merge conflict. Hard to tell if you don't have the messages. See here that git merge does indeed use the default upstream if no commit argument is given: https://www.kernel.org/pub/software/scm/git/docs/git-merge.html – 31eee384 Sep 03 '13 at 16:31
  • Hmm, maybe you don't have the config var set that enables upstream as default--I don't know what happens when it isn't. Here's another answer that might clarify though: http://stackoverflow.com/a/3427698/382780 – 31eee384 Sep 03 '13 at 16:38
  • 1
    "I'm on the origin/develop branch"? If you want to merge with the remote branch, say `origin/develop`, you should stay at the local branch, say `develop`, and then run `git merge origin/develop`. – teloon Sep 03 '13 at 16:45
  • Sorry, edited my Q.. I had actually typed "git merge origin develop." Argh. If there's ONE thing I hate about git, it's the syntax inconsistency ("git merge origin/develop" vs "git push origin develop"). I feel like they should've stuck with the slash syntax across the board. So this is probably why I encountered an error. – CaptSaltyJack Sep 03 '13 at 16:53

1 Answers1

1

You should've used git merge @{u}. @{u} is shorthand for the remote tracking branch (e.g., origin/master). It looks like you might be working with a branch called develop, so this would be the equivalent: git merge origin/develop.

I can't remember if pull will now ask you to provide a message for an actual merge--in the case that it cannot just fast-forward. So, the full command might be more akin to git merge --no-edit @{u}.

John Szakmeister
  • 44,691
  • 9
  • 89
  • 79
  • Whoa. Where can I get a full list of those shortcuts? – CaptSaltyJack Sep 03 '13 at 17:20
  • Look in the "Specifying Revisions" section of [`git rev-parse` man page](http://git-scm.com/docs/git-rev-parse) (you can get to it via `git help rev-parse` too). – John Szakmeister Sep 03 '13 at 17:52
  • 1
    @CaptSaltyJack I would like to point out that if you're using Git bash tab-completion, simply typing `git merge or` then hitting tab should autocomplete to `git merge origin/`, then typing `de` and hitting tab again should autocomplete the whole thing to `git merge origin/develop`. **Problem solved**! –  Sep 03 '13 at 22:29