Home > Software design >  Git best practice
Git best practice

Time:10-24

Hi I'm new to Git and wondering how I should approach the following scenario.

I have a development branch which im working on new features, then I realise my live app has a bug. I fix the bug on master. I now want/need the bugfix on the development branch.

How should I deal with this? Do I go to the development branch and merge master?

CodePudding user response:

This is one of many scenarios where git really shines.

All you have to do is pull master into your development branch by checking out the feature branch and issuing a

git pull origin master

If the development branch conflicts with main because the bugfix changes the same lines as the development branch, you may prefer to rebase your branch on top of master.

git rebase -i origin/master

This re-applies your changes as if they were done after changes currently on master and can make for a cleaner merge in some cases.

You can safely experiment with both of these commands by branching off your development branch into a throw-away test branch, then using git diff to compare your throw-away branch with your development branch.

  •  Tags:  
  • git
  • Related