Git merge loses current changes on branch being merged to

Default version uses master branch in Git. Another branch contains changes which will be merged to master.

Meanwhile, another developer has made changes in the Default version (master branch) which are *not committed* (which is not great, but might not be avoidable).

When I then perform a Git merge into master from another branch, those changes in master are completely removed. This is not normal Git behavior as far as I can tell, those changes in master should be retained as un-committed (but they are not, which seems like a bug to me).

Correct behavior on my box:

username@hostname:~/temp/git_test $ git init

Initialized empty Git repository in /home/username/temp/git_test/.git/

username@hostname:~/temp/git_test $ git status

username@hostname:~/temp/git_test $ echo "testing" > test_file

username@hostname:~/temp/git_test $ git add .

username@hostname:~/temp/git_test $ git commit -m "First commit"

[main (root-commit) 104b85e] First commit

1 file changed, 1 insertion(+)

create mode 100644 test_file

username@hostname:~/temp/git_test (main)$ git branch my_branch

username@hostname:~/temp/git_test (main)$ git checkout my_branch

Switched to branch 'my_branch'

username@hostname:~/temp/git_test (my_branch)$ echo "other file" > other_file

username@hostname:~/temp/git_test (my_branch)$ git add .

username@hostname:~/temp/git_test (my_branch)$ git commit -m "Adding other file in my_branch"

[my_branch 1b45ddb] Adding other file in my_branch

1 file changed, 1 insertion(+)

create mode 100644 other_file

username@hostname:~/temp/git_test (my_branch)$ git checkout main

Switched to branch 'main'

username@hostname:~/temp/git_test (main)$ echo "new file" > new_file

username@hostname:~/temp/git_test (main)$ git status

On branch main

Untracked files:

(use "git add <file>..." to include in what will be committed)

new_file

nothing added to commit but untracked files present (use "git add" to track)

username@hostname:~/temp/git_test (main)$ git merge my_branch

Updating 104b85e..1b45ddb

Fast-forward

other_file | 1 +

1 file changed, 1 insertion(+)

create mode 100644 other_file

username@hostname:~/temp/git_test (main)$ git status

On branch main

Untracked files:

(use "git add <file>..." to include in what will be committed)

new_file

nothing added to commit but untracked files present (use "git add" to track)

username@hostname:~/temp/git_test (main)$ ls

total 24K

drwxr-xr-x 3 username username 4.0K 2022-12-15 10:20 .

drwxr-xr-x 13 username username 4.0K 2022-12-15 10:18 ..

drwxr-xr-x 8 username username 4.0K 2022-12-15 10:20 .git

-rw-r--r-- 1 username username 9 2022-12-15 10:20 new_file

-rw-r--r-- 1 username username 11 2022-12-15 10:20 other_file

-rw-r--r-- 1 username username 8 2022-12-15 10:19 test_file

username@hostname:~/temp/git_test (main)$

Hi @sverzel

Sorry to hear you have met this issue, I would recommend raising this with our support team via support@matillion.com

They will be able to look at this and raise it internally for you.

Kind regards, Joe