0

I am trying to merge branch name lms-development into cms-development. it is adding 5 files which do not present in both of their local version. I am sure, I am not merging any other versions.

I used git merge --no-ff --no-commit lms-development while merging.

I have also checked these 5 files are not in untacked.

what I did previously in history in the repo in other branches and merges.

I ignored some of the files during merge previously by

  git rm --chached PATH_TO_FILES
  git reset PATH_TO_FILES
  git reset HEAD -- PATH_TO_FILES
  git rm -rf PATH_TO_FILES

I have done the above things in many merges because of requirements.

Is this thing can create such an issue.

Let me know if other things in git can create such an issue as well. I might don't have any idea about thing that other developers did something.

We are using 2 branches for two different microservice, both of these branches have different folders and some common folders. I merge these branches to each other. during that merge, I ignore files by the above technique so that I can ignore folder of specific microservice and can have updated common code.

Any thoughts on this could be grateful.

amer
  • 1,528
  • 1
  • 14
  • 22
  • 1
    `git merge` merges *commits*, while `git rm --cached` merely removes a file from the index. (You can't start a merge with a dirty index, though. Your reset presumably un-dirtied the index. There is no `git reset --head`, perhaps you meant `git reset --hard`.) `git rm` removes a file from both the index and the work-tree. You must commit afterward to make a commit that lacks the file. – torek Jan 09 '20 at 07:29
  • 1
    In any case, you cannot ignore files during a merge. The merge merges *commits* and it merges changes found by comparing those commits to the *merge base*. So what matters is what is in the merge base commit and what is in each tip commit. *All* those files will be merged. Perhaps you are being misled by *untracked* files that reside in your work-tree. – torek Jan 09 '20 at 07:31
  • @torek, thanks for replay. I have checked again in both branch the files which are coming in the merge is not present in both the branches. And sorry previously question was misleading. I am not ignoring file in merge which is giving issue. it is just a simple merge commit. in history, I have ignored files using https://stackoverflow.com/questions/15232000/git-ignore-files-during-merge this approch. – Ashish Vavaliya Jan 09 '20 at 09:05
  • That question (and its answers) does not *ignore* files, it just sets a *merge driver* that is used only when the specified file is different in all three commits (merge base and both branch tips, again). I'd suggest you step back a bit and find the merge base and the two branch tips, then use `git ls-tree -r` on the three commits to see what files Git sees, and use `git diff --find-renames ` to see what changes Git sees. – torek Jan 09 '20 at 17:31

0 Answers0