I am working on a large scale project that has been messed up by our predecessors. We are planning to clean all **bleep**ty code (maybe by rebuilding it in Laravel), but before that we have to develop the current application further. Otherwise our customer comes to a halt in production.
One developer thought of a way to develop each new issue in a new branch. We have 3 main branches: “development” - “acceptation” - “master”. When a new issue arises, we branch off of master to a new branch called “issueX”. Another issue? Make branch off of master “issueY”.
But when you work on both issues yourself, and you have changes on the same file code gets intermixed. Say you have made changes to “module.php” within branch issueX. After that you checkout to branch issueY and make other changes to again “module.php”. After committing, branch issueY will contain some code of issueX.
Another problem is with hotfixes. I really have to change hotfix code in GitLab with the online IDE editor, because otherwise I definately will commit some development code to the hotfix branch, and therefor be putting some code live in production after deploying the hotfix!
How can I checkout to different branches, committing to them without committing code from other branches? I need to be able to get my environment synced with the branch 100%. So even when I have created a new file for issueX, after checking out to issueY that new file must be gone!
Right now I am thinking of these 2 commands:
git checkout issueY
git reset --hard
Would that be a good way to go? Or is that a weird strategy? I would love to have your thoughts about this. Thanks a whole lot in advance!