Merging branch into master is not keeping, or recognizing certain file changes.
Asked by Mitchell Jurich:

I'm using Sourcetree to mange a Bitbucket account for a Unity engine project I'm working on. Unity uses an Assets folder which holds image files, game world files, etc.

I created a branch to fix a bug, and inside this branch I deleted several files in the Assets folder (mostly PNG images) and added several new ones as well as modified some other pertinent files. I've commited the finished changes to that branch just fine, however now that I'm attempting to merge these changes into master, Sourcetree seems to act as if there are no changes to any of the files in this Assets folder. After it prompts me to resolve conflicts, when I look at the working copy the entire Assets directory isn't even visible when viewing "Pending" or "Conflicts" files. These files are visible when I select to view "Clean" files, and there seems to be no insinuation at all that the branch I'm attempting to merge from has deleted or added files in this directory.

Any ideas what's going on in this situation?

EDIT: The Assets directory is not specified in the .gitignore file.

EDIT2: If I use ctrl to select the master and branch together, I am able to view the changes which are correctly reflected. However the problem arises when attempting to merge.


Answers:
author: Mitchell Jurich
body: It seems like the issue is something to do with git and not Sourcetree in particular. I attempted to merge using the git terminal and had the same issues arise, so my somewhat hacky and non-elegant solution was to simply create a new branch off master, paste all the files from the troublesome branch into that new one, commit that branch, and then merge it into the master branch. This merge was successful so it seems like git has some issue with the tracking on the original branch for some reason.


author: minnsey
body: Hi,  

After the merge are the files the *new* versions?  

Would it be possible to add some illustrative screenshots?

comments: author: Mitchell Jurich
body: After the merge the files are the older versions (the ones in master NOT the ones in the branch). Here's some pictures for example:

**Here is the Assets/Sprites/Player directory in the sprites_blurry branch:**

![branch.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/48019i3C9F93C1D0E861BC/image-size/large?v=v2&px=999 "branch.PNG")

**Now here is that same directory in the master branch:**

**![master.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/48020i0AF5151BF6297C3B/image-size/large?v=v2&px=999 "master.PNG")**

**We can check the differences between the two branches here:**

**![diff_against.png](https://community.atlassian.com/t5/image/serverpage/image-id/48023i2A6258F4251C9530/image-size/large?v=v2&px=999 "diff_against.png")**

**And we see that the pictures do, indeed show up as different:**

**![differances.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/48024iADE970042B261DFF/image-size/large?v=v2&px=999 "differances.PNG")**

**Now with the master branch checke** **d out we attempt to merge the blurry_sprites branch into the master:**

**![merge.png](https://community.atlassian.com/t5/image/serverpage/image-id/48025i1D0CB3FE7A9390F4/image-size/large?v=v2&px=999 "merge.png")**

**It says conflicts need to be resolved so we look in the working copy. However, the pending files don't recognize any of the contents of the Asset folder as being altered:**

![pending.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/48026i2394E50803572730/image-size/large?v=v2&px=999 "pending.PNG")

**We can see this when we view the clean files, and the Asset directory is visible, containing the master's version of those files, but no reference to the branch's deletion of them or inclusion of new files:**

![clean.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/48028i397B0BB70A546A82/image-size/large?v=v2&px=999 "clean.PNG")


author: minnsey
body: Hi  

I'm not quite following the pictures. In both the master and hotfix branches those files are listed as unstaged and therefore not committed etc. Shouldn't all the files be committed in the hotfix branch so they can be merged to master?


author: Mitchell Jurich
body: The files have been and are shown as commited and pushed on the Bitbucket server.


author: Mitchell Jurich
body: I would assume they are listed as unstaged because there is no changes between them and the last commit. In those example pictures I am switching between the two branches by checking them out respectively. In the first picture the hotfix/sprites_blurry branch is checked out and the contents of the last commit to it are visible. In the second picture the master branch is checked out and the contents of the last commit to it are visible.


author: minnsey
body: Are you changing branches after you started the merge to master?  

I.e.

1. you commit everything in the hotfix branch, so the staging view is empty.
2. Then you switch to master
3. Then you merge in hotfix, this then shows the uncommitted changes because there are conflicts
4. Then you switch branch back to hotfix before completing the merge in master


author: Mitchell Jurich
body: Nope, I'm not switching branches mid merge. Here's a picture after attempting to merge if that helps at all.

![merge_attempt.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/48037i5B0A0A19C0D208F4/image-size/large?v=v2&px=999 "merge_attempt.PNG")


author: minnsey
body: Yes I'd expect to see that.  

But this one looks odd  

![branch.PNG](https://tnckb94959.i.lithium.com/t5/image/serverpage/image-id/48019i3C9F93C1D0E861BC/image-dimensions/2500?v=1.0&px=-1 "branch.PNG")

Why is there a merge and uncommitted files showing in this branch my understanding was you'd committed everything in this branch?


author: Mitchell Jurich
body: Ah, in this picture I had attempted the merge commit but discarded the changes because it wasn't working properly as previously mentioned. It seems it kept that comment in the box below even though the merge commit never happened.

Without that discarded merge attempt, here is the working copy of the hotfix branch:

![current branch window.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/48050i01421295841DDFF5/image-size/large?v=v2&px=999 "current branch window.PNG")


author: minnsey
body: I'd be interested to see what Git thinks of it, if you do the merge from the console/terminal?