0

Lets say I have two branch like this:

o---o---o---o---o master
\
 o---o---o feature

If I run the following commands:

$ git checkout master
$ git merge feature

what will happen?

o---o---o---o---o master                     o---o---o---o---o master
\              /                or this       \               \   
 o---o---o---- feature                         o---o---o-------o feature  

3 Answers3

2

The former, per the git-merge manual:

Description

Incorporates changes from the named commits (since the time their histories diverged from the current branch) into the current branch.

[...]

Assume the... current branch is "master"... Then "git merge topic" will replay the changes made on the topic branch since it diverged from master until its current commit on top of master, and record the result in a new commit along with the names of the two parent commits and a log message from the user describing the changes.

Or, preserving the lovely formatting of http://git-scm.com:

git merge info

bertieb
  • 7,543
2

git merge branch_name merges branch_name into your current branch. In your case the result will be

o---o---o---o---o master
\              /
 o---o---o---- feature

And a merge commit will be added to master.

gronostaj
  • 58,482
1

The feature branch will be merged into master. You can test this out quickly in a temporary git repo.

> git init
> echo test > testfile
> cat testfile
test
> git add testfile
> git commit -m "First commit"
> git checkout -b feature
> echo test2 >> testfile
> cat testfile
test
test2
> git commit -am "Second commit"
> git checkout master
> cat testfile
test
> git merge feature
> cat testfile
test
test2
Kris Harper
  • 1,047