Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does 'git merge' with no arguments do?

Tags:

git

I've seen people doing

git merge

i.e. using "git merge" with no arguments. It looks like it might do something useful. But I couldn't find documentation for this scenario on git-scm.com.

What does "git merge" do in this scenario?

like image 621
zgpmax Avatar asked Sep 15 '16 07:09

zgpmax


People also ask

What does git pull without arguments do?

Without any arguments, git merge will merge the corresponding remote tracking branch to the local working branch.

What does git merge actually do?

Merging is Git's way of putting a forked history back together again. The git merge command lets you take the independent lines of development created by git branch and integrate them into a single branch.

What does git merge -- no FF mean?

The Git merge --no-ff command merges the specified branch into the command in the current branch and ensures performing a merge commit even when it is a fast-forward merge. It helps in record-keeping of all performed merge commands in the concerning git repo.

Does it matter which way you merge in git?

Usually it does not matter if both branches are topic or feature branches. However, if you have an integration branch or a branch that marks what's been published, you definitely want to use the long lived integration branch as the one that's checked out and merge the other one into it.


1 Answers

It would try and merge its upstream branch (git merge)

If no commit is given from the command line, merge the remote-tracking branches that the current branch is configured to use as its upstream.

So check, to see if a branch has an upstream repo associated to it:

git config remote.$(git config branch.$(git symbolic-ref --short HEAD).remote).url

This uses:

  • "Find out which remote branch a local branch is tracking"
  • "How to get the name of the current git branch into a variable in a shell script?"

For Windows, crashneb suggests in the comments:

for /f %b in ('git symbolic-ref --short HEAD') do \
  @(for /f %r in ('git config branch.%b.remote') do \
    @(git config remote.%r.url))
like image 79
VonC Avatar answered Sep 18 '22 19:09

VonC