techsjs2013
techsjs2013

Reputation: 2627

Why don't I have to commit after git merge

I have a repo master and I do with file1.txt and file2.txt

git checkout -b fix1

I then change file1.txt

and I do a

git commit -a

then I do a

git checkout master

then I do a

git checkout -b fix2

I then change file2.txt

and I do a

git commit -a

then git checkout master then a

git merge fix1
git marge fix2 

but if I do a

 commit -a 

I get

# On branch master
nothing to commit (working directory clean)

Upvotes: 18

Views: 16777

Answers (3)

Darin Kolev
Darin Kolev

Reputation: 3409

The merged files, which don't have conflicts are already merged. You can directly push your merged files.

Upvotes: 1

Some programmer dude
Some programmer dude

Reputation: 409472

git merge commits automatically. If you don't want to commit add the --no-commit argument:

  --commit, --no-commit
      Perform the merge and commit the result. This option can be used to override --no-commit.

      With --no-commit perform the merge but pretend the merge failed and do not autocommit, to give the user
      a chance to inspect and further tweak the merge result before committing.

Upvotes: 27

eldarerathis
eldarerathis

Reputation: 36243

If the merge succeeds without conflict, git will automatically commit it (which you should be able to verify by simply checking git log).

The documentation notes (emphasis added):

... "git merge topic" will replay the changes made on the topic branch since it diverged from master (i.e., E) until its current commit (C) 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

If you want to avoid this, use the --no-commit flag:

git merge --no-commit fix1

Upvotes: 3

Related Questions