dead programmer
dead programmer

Reputation: 4365

no conflict on second time merging

I a new learner of git. I checked a file with "myfile.txt" with the content as

first commit in master.

committed the change in master branch with git commit -a -m "first commit"

In second step I created a branch from master mysecondbranch branch. and add a second line.

first commit in master.
**second commit in mysecondbranch.**

again commiting the changes in mysecondbranch

now switching back to master branch. and added new content as

frst commit in master.
**second commit in newbranch.**

and commited the changes to master branch.

next I want to merge the changes in mysecondbranch using the command as

git merge mysecondbranch

this time as expected it there is a conflict while merging..

the problem starts here I discard the change of merge using

git reset HEAD myfile

try the merge again But I am surprised this time there is no conflict and there is no result of git diff

I am getting the error as fatal: commit your changes before you can merge.

Upvotes: 0

Views: 196

Answers (2)

Oleksandr Vyshniakov
Oleksandr Vyshniakov

Reputation: 251

Use

git reset --hard master

instead of

git reset HEAD myfile

to discard the changes

Upvotes: 1

Makkes
Makkes

Reputation: 1816

When you issue

git reset HEAD myfile

you don't discard the changes of the merge. Do a

git status

after the reset and you'll see that you have unstaged changes. If you want to really discard the changes from the merge do a

git reset --hard HEAD

after the call to merge.

Upvotes: 2

Related Questions