18

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) 

3 Answers 3

27

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. 
Sign up to request clarification or add additional context in comments.

Comments

3

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 

Comments

1

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.