4

This question is very similar to this question on merging but with one key difference: the absence of a merge conflict.

So I'm working in a feature branch, commit some changes, and run git merge master. My goal is to update my feature branch with the latest master before I create a PR to merge the branch back into master (that is our chosen workflow, the idea is to resolve issues on feature branches first). I get zero merge conflicts and the merge seems to complete. When I run git log it appears that my feature branch now has the latest commits from master. However, when I run git status a bunch of files that I did not touch (but which appear to have been updated in master) suddenly enter my list of "Changes to committed", and a smattering of them appear as "Changes not staged for commit" and "Untracked files". It is not 1-to-1, in my latest example I had 45 files staged, but only 33 that were unstaged+modified or untracked. I am not committing these files as it does appear the feature branch already has the latest commits from master.

I have to date been dealing with this issue just by running git stash (and clearing my stash periodically). Sometimes I run get reset HEAD to clean it up too. This seems ok since I have the latest commits from master. However, I am not sure if these are desirable actions or the right thing to do. Am I missing a crucial piece of the git merge workflow by ignoring these staged files? What is going on here? What is the name of this behavior? I can't find a reference to this in any of the guides I've read.

One final note that might help. I am on a Mac, but this is a .net + React project, so many devs are on windows. Could this be an issue of autocrlf or other line ending variations between the platforms?

R V
  • 133
  • 1
  • 8
  • Use `git pull --rebase origin master` instead. Back merges is not good idea. – 0andriy Jul 02 '18 at 19:12
  • 1
    CRLF line ending issues are possible. To find out if this is the case, check for `.gitattributes` files with EOL directives, and check your own `core.autocrlf` setting. – torek Jul 02 '18 at 20:15
  • 1
    The question is perfectly stated. Your workaround (stashing and then ignoring) is essentially the same as in [this answer](https://stackoverflow.com/a/50064776/264097) to essentially the same question. But none of the answers explain _why_ it happens. Have you found this out since four years ago? – Alex Fainshtein Apr 24 '22 at 07:13

0 Answers0