I'm making an E-commerce website using django and web(HTML/CSS/Js).
I'm planning to host the app on Heroku, so for that, I'll need to create some files and do minor changes in the project directory, which are just for heroku, and not the project itself.
I'm maintaining a master branch which will be updated more often.
For heroku, I'm planning to create a different branch named heroku or something, that will contain the heroku related files and changes.
What I want to do is
Whenever I make any commits to the master branch, I want to get the commits from it to the heroku branch.
The commits I make to the heroku branch shouldn't be related or reflected in the master branch (provided, I'll only make changes to the heroku specific files, and not the common files).
How can I achieve this functionality?
Currently I only have master branch on my git repo and remote repo.
The heroku branch will just be present for live site, and main changes will be made on master.
I'm new to heroku, and I haven't used it yet.
CodePudding user response:
You can try GitHub actions (or bitbucket pipelines) for ci-cd and create a pipeline for master branch that merges master branch to your new branch.
You can follow this Link for auto-merging a pull request using github action.
This Link can also be helpful.
CodePudding user response:
I have figured out a way, but that is not by git CLI.
I use VsCode for editing my code. The folder is a git repo, so vscode automatically gives features of git.
I created a branch named heroku besides my master branch and published the branch to my remote.
Now, my remote has the branches, heroku and master.
I made changes to heroku branch and pushed it to the remote. I made different changes to master and pushed it too.
Now my repo has different file histories for both my branches. In order to get the changes from master to heroku, I opened VsCode, went to Git section, then from options, I clicked on Pull from, then selected origin and then origin/master.
By doing this, the changes from master reflected on heroku branch locally. Now, I had to push the changes.
By this, I'm able to achieve the goal, but I haven't tried editing the same file on both branches and then perform the steps.. I guess changes to same file won't be a good idea.