7

I have a MEAN stack project separated into two branches: Ionic and Node.

The Ionic branch have all Ionic related files/folder. The front-end is created here to serve mobiles and web devices. But the code for web devices from this branch is not hosted anywhere.

The Node branch have server related files/folder. This branch will be uploaded to host the application end-points and will need to serve a public front-end folder. The front-end folder comes from the Ionic branch.

I've read this post about spliting a commit into separate commits, so we can ignore one of them. This don't solve the problem because I have lots of files and folders that should not merge and would be very hard to separate them all in each and every merge. I need only the front-end/public/www folder to merge into the Node branch.

I also read about this, this, this and a lot more relevant questions on Stack and articles on the internet, but none of them could address my issue.

We have a Node and an Ionic branch. The Node branch need to have only specific files and folders from the Ionic branch. How can we do that?

Appendixes

Branch Node example:

¬ node_modules
¬ routes
¬ www
¬ files/etc

Ionic Node example:

¬ node_modules //this should not merge into Node
¬ hooks        //this should not merge into Node
¬ resources    //this should not merge into Node
¬ www          //MERGE THIS
¬ files/etc    //some should merge, some should not.
Community
  • 1
  • 1
Rodmentou
  • 1,610
  • 3
  • 21
  • 39
  • Only the 'www' folder should be on the same path on both branchs. I could change others, if needed. Only the 'www' folder from Ionic will be used on production. – Rodmentou Dec 07 '15 at 23:28
  • 1
    This [Question](http://stackoverflow.com/questions/449541/how-do-you-merge-selective-files-with-git-merge) should help. – manishrw Dec 08 '15 at 05:46

1 Answers1

5

This is from top of my head so it is only an idea to try out.
If I understand correctly you want to selectivly merge ionic onto node

git checkout node
git checkout -b temp
git checkout -p ionic -- www
# solve merge conflicts
# git add or git add -p (interactive per diff adding)
git checkout -p ionic -- files/etc

git checkout -p and git add -p should give you interactive option of adding and checking out paths/files/parts of files.

git checkout --help
-p --patch Interactively select hunks in the difference between the (or the index, if unspecified) and the working tree. The chosen hunks are then applied in reverse to the working tree (and if a was specified, the index).

This means that you can use git checkout -p to selectively discard edits from your current working tree. See the “Interactive Mode” section of git-add(1) to learn how to operate the --patch mode.

edin-m
  • 3,021
  • 3
  • 17
  • 27