-1

My team is developing a project in Laravel and recently we had to make a new branch because of different front end.

Is it possible somehow to apply the changes from one branch to another and vice versa but so that the front end is untouched.

This should be somehow separated because of the front end so whenever we work on front end we push to same branch, but if we work on backend then it should be pushed on both branches....How to do this?

It should be something like this:

enter image description here

lewis4u
  • 14,256
  • 18
  • 107
  • 148
  • By front end do you mean another branch (i.e. master?) – cowboydan Aug 31 '16 at 12:06
  • 1
    It sounds like maybe you should be separating things into two repositories. – larsks Aug 31 '16 at 12:13
  • *"but so that the front end is untouched."* -- the picture you added to the question displays merges between branches. The merges synchronize the content of the two branches, it doesn't help you achieve the *"is untouched"* goal. – axiac Aug 31 '16 at 13:17

3 Answers3

1

When you work on the backend you need to first push to one branch and after that do a "git cherry-pick" to the second one:

> git checkout <second-branch>
> git cherry-pick <first-commit>

More info: git help cherry-pick

  • this should be the solution for my problem....can you describe it or give some links on this "git cherry-pick" i have never used it – lewis4u Aug 31 '16 at 12:31
1

Not quite clear if your front-end and back-end are in the same git repo or not, but if possible I would recommend making each component (i.e. front-end and back-end) into separate repos.

This link details such a process. This way you can have the back-end be independent of the front-end, eliminating the problem. This would come at the cost of taking care of where you place the front-end and back end repos on your dev machine so they link to each other, which is a small price to pay for a coherent version control system.

Community
  • 1
  • 1
cowboydan
  • 1,062
  • 7
  • 15
1

Make sure you don't mix changes on front-end with changes on back-end in the same commit on the main branch. Use separate commits for front-end and back-end changes.

Then you can cherry-pick into the feature branch only the commits that you need from the main branch (only the back-end commits.

This way the feature branch can be kept up to date with the main branch without pulling into it the changes it doesn't need (the changes in the front-end).

axiac
  • 68,258
  • 9
  • 99
  • 134