While merging into the master branch it merges files that are already merged in master via different branch

Master branch M Feature branch f1,f2,f3

M <-f1

git clone http://test.com/test.git git checkout M

Open file in PHPstorm .It asked to Open project .clicked on confirm

git checkout -b f1
git status 
# it shows all file as modified even only file1 is updated

Open desired file file1 did the modification and saved it

git commit file1 -m 'f1 branch' 
git push -upstream f1
 git checkout M 
git merge f1 

git log -1 --stat

shows only 1 file file1 it merges file1 git push. The process is done properly but when tried same with branch f2. it merges file1 and file2 same goes for push where I am going wrong. But on each merge in master, it pushes previous branches files

Step where actual issue Occurs

git checkout -b f2

Open file2 in phpstorm modify and save the file

git status  

All files are shown as modified whereas only file2 was actually updated

git commit file2 -m 'test for f2'
git push -upstream f2
#push only file 2
git checkout M
git status
o/p Your branch M
your branch is ahead of 2 commits
git merge f2
#it merges file1 and file2
git push
#it pushes file1 and file2 

My 2 questions:

  1. How to open the project that is under git repository via PHPstorm. Is it the main cause to show all files as modified
  2. What wrong i am doing in merge or is there any method to just merge few files and push only few files in main branch.

Had taken reference from How can I merge two branches without losing any files?

Have updated the question is it clear

  • It is really unclear what you are trying to do. Are you able to clarify your question? – Burgi Mar 1 at 11:30
  • Try to have a look why you're seeing every file as being modified. Check how you setup git to handle line endings, what PHPStorm uses and what's in the files after a checkout. – Seth Mar 1 at 12:14
  • @Burgi is it clear now? Actually, i am trying to merge different files from different branches to master. It worked well in first merge and push. But while merging the second branch it had merged files that were already merged in the previous branch. – insoftservice Mar 1 at 12:15
  • @Seth that's my question does phpstorm modifies the files. As i have just open the folder in it have not done any git settings as i don't know about it . Same if pulled on my colleagues laptop which has phpstorm has no issue. – insoftservice Mar 1 at 12:18
  • You are the one on the computer. You will have to compare those files. Nobody can do that for you. Especially since your git settings also matter and only you know how you set it up. Grab the file, do a checkout, grab it again and compare it with your favorite tool. Are they different? If so either your editor or git modifies the file. – Seth Mar 1 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.