Consider a scenario in which I have created a branch from master called "Feature 1". My friend also created a branch from master called "Feature 2". He finished his code changes and merged "Feature 2" branch back to master.
Now I have completed my changes in "Feature 1" branch and want to merge back to master ( which has been updated since I branched of it ). Do I need to pull / rebase before I can merge "Feature 1" to master or is that something git will handle?
It's not necessary to update your master branch before you merge your feature branch into it. However, that is not the best practice. You are better off doing the following:
Doing it this way will ensure that your commits are the most recent in the history and that any merge conflicts are handled on the feature branch, not the master branch. This keeps your master branch clean and your history cleaner. The other people using your repo will be happy.
The commands will look like this:
To elaborate on what each command will do:
master
, which is outdatedmaster
, applying any local changes master
has on top (none, if you used branches for edits)feature1
branch that's still based off the outdated "master"feature1
changes on top of master
, which was updated in #2master
, which is updated but still without your feature1
changesmaster
changes on top of feature1
, but since feature1 is a direct child of master, this just updates master again with your feature1 changesgit push
to "publish" your changes to master to the repoIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With