How to use git branches with live updates and merge with master?

I have a website where the master is checked out and a development website where I develop in feature branches.

When the function is merged into master, I do this on the development site:

(currently on the new-feature branch)
$ git commit -m"new feature finished"
$ git push
$ git checkout master
$ git merge new-feature
$ git push

      

And at the production site:

(currently on master branch)
$git pull

      

This works for me. But sometimes a customer calls and needs small changes to the website quickly. I can do this in production on master and push master and it works great.

But when I use the traits branch for a small change, I get a space:

(On production on branch master)
$ git branch quick-feature
$ git checkout quick-feature
$ git push origin quick-feature
$ edit files...
$ git add .
$ git commit -m"quick changes"
$ git push # until this point the changes are live
$ git checkout master #now the changes are not live anymore GAP
$ git merge quick-feature # now the changes are live again
$ git push

      

Hopefully I can point out this workflow clearly. Can you recommend something better?

+2


a source to share


2 answers


if the swift branch is being developed on top of the master, you can reset the master branch while in the swift branch:

git branch -f master

      

This way you avoid checkout master

which temporarily removes the shortcut function from your working tree.

x--x--x  (master)
       \                          => x--x--x--f--f--f--f (master, quick-feature)
        -f--f--f (quick-feature)

      




Another solution when you switch back to master is to ask for a merge

 git checkout --merge master

      

This allows the modification to be saved quick-feature

while taking into account the current state of the master.

+1


a source


"making changes to production" is simply wrong, you shouldn't.

Correct workflow: - check wizard on test / devel / sandbox / server / whatever - make changes, change test - commit change, merge into master, deploy to production



what branches are for. You can even make your workflow more automated by using hooks in git, which automatically deploys whatever you "w21> push" to a specific branch, which can be the master branch or the other.

0


a source







All Articles