Question

I have a git repository that has one file called hi.txt. It has only one branch i.e. master. Its content is Hi this is it. I committed this change and then checked out it in a new branch called newb using git checkout -b newb. Now in this branch i changed the text to Hi this is not it. I committed this code too. Now i switched to master using git checkout master and then merged the newb branch using git merge newb. Now git should give me a conflict because both branches have different versions of the same file but it does not. It overwrites the content of masterbranch with newb branch so content of hi.txt becomes Hi this is not it. Is this how it is supposed to work?

Was it helpful?

Solution

Why shall there be a conflict?

  • you created hi.txt in master
  • you created a new branch newb and modified hi.txt
  • you switch back to master and the changes done in newb are merged into master

That's the way it should work. We're not using SVN, eh?

Things could be different if you changed hi.txt in master after creating newb: this would lead to a state where there are modifications on both branches.

But your workflow described above shall not lead to any problems.

Have a deeper read about branching and merging in the Git Book:
http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging


Edit: According to your comment, you only want to know which files are different between master and newb. This can easily be achieved using

git diff --name-only master newb
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top