0

I have been working on my web-project on my localhost with xampp and Git. I created two branches on Git - a developer branch where I developed new features and a master branch where I merged new features from the developer. The master branch was supposed to include the code which would be published on my webhost as soon as I would be ready to publish my project.

When I was ready to publish it on my webhost, there were of course settings which were different then on my localhost, like link settings, different database access data and so on. So to make the project running I had to make changes to my files located in the master branch.

In a perfect world I know I would have just one settings file which would be different in master and developer and the rest of the code would be the same, unfortunately I am not perfect. So I have now on the master and on the developer branch two slightly different codes, but whenever I want to include a new feature on the developer branch, I can not just merge it to the master, since this would lead to changes in master by code which should not be changed.

My question now is, how can I tell git, that from a certain point in the developer branch I want to merge commits again to the master? If this was possible I thought to make e.g. new functions in developer branch, commit those changes and merge exactly this commit only (and not previous onces) to the master. Is the rebase of Git a possibility to help me in this case?

EDIT: following workflow helps to understand my problem:

  1. myFile.php contains on developer: path="localhost";
  2. add + commit + push to developer
  3. switch to master
  4. merge with developer. Now I have the file myFile.php on my master branch
  5. I am chaning the path in this file to path="www......"
  6. commit and push at master branch
  7. switch back to developer
  8. Adding function myfunc() to file myFile.php at developer branch
  9. commit and push at developer branch
  10. switching to master
  11. merge in master branch with developer branch - now on my master branch the file myFile.php contains the new function but also the path variable changed back to path="localhost" - now I have again to change this on master branch to path="www...." and make again a commit and push

BR, eMu

Emad Easa
  • 79
  • 1
  • 10
  • Of course I can you are right, what I wanted to say is, lets assume I have a file with a variable path="localhost" in the developer branch. After merging to the master I have to change this variable to smt. like path="www......" After the change on master I will commit it and push it on master branch. When I extend the same file now by a function on the developer branch and commit it and then start a merge to master, the change in the path variable would be overwritten and I have to change the path again to path="www......." – Emad Easa Jan 06 '22 at 18:24
  • 1
    [Don't put real settings in committed files; use templates instead.](https://stackoverflow.com/q/40317063/1256452) – torek Jan 06 '22 at 20:02
  • I added the workflow where I face the problem in my original post. Yes I tried and suffered from it already. – Emad Easa Jan 07 '22 at 06:37
  • @matt: Thx. for your suggestion. This might be a solution, but would cost me some time to change codes and bring both branches in sync again - is there a possibility where I can make kind of cut in the developer branch and tell it, to merge only commits "from now on"? – Emad Easa Jan 07 '22 at 10:16
  • A commit always contains a _full_ snapshot of all your project's files. You cannot "merge a single commit, but not previous ones". In a way, a commit _always_ includes all its previous commits. – knittl Oct 20 '22 at 20:05

0 Answers0