Reputation: 5361
I have a feature branch that works off of a pretty active master branch.
I've been rebasing with master before pushing to my remote. I've now PRd my branch with master.
What are recommended approaches to keep my feature branch up to date with master as this is still a work-in-progress?
I'm working on a new project with a large team and active master branch, so I haven't come across this issue before.
Upvotes: 1
Views: 13723
Reputation: 609
I merge master to my private branch when there are larger changes in master, after I make a large changes (and all tests are OK, then I run tests again and fix all what get broken) and for sure I would merge master to my branch (and run the tests and fixed) BEFORE I would try to merge it back to master.
But I usually merge master at beginning of every day anyway, to be in close sync. And I tend to keep my branches small and short, just as big as one feature needs (including all related changes).
If I can improve two things, I start branch for each one. It is simpler to found problems later with every branch relatively small and closed, then with branches, which does too much and unrelated changes.
It is my responsibility to have branch in state, where it works perfectly and could be fast-forward to master, before I even thing about merging.
(BTW, our model is "super stable" production, with squashes like 1.0.1, 1.0.2 ..., then stable devel, where every production is merged back and then "private and experimental" feature branches, which are squashed to devel, when finished and tested.
So our devel looks like serie of small commits, where each of them solves just one problem in just one genial step :) If something goes wrong, bisection is relatively fast and leads to source of problems directly, as there are no half-way done or unfinished commits at all.)
My workflow is like
git checkout -b f_improve_bar
[:
[:
hack, hack, hack
test
:]
merge origin/master
test
:]
git checkout master
git merge --squash f_improve_bar
test
git commit -am "merged f_improve_bar"
Upvotes: 0
Reputation: 1782
The flow to make you 'feature' branch up to date is the next:
git checkout feature-branch
//working on a feature
git add --all
git commit -m "commit message"
git fetch upstream master
git rebase upstream/master
// fix conflicts if exists
//working on a feature (doing add + commit)
git push origin feature-branch
Rebasing your feature branch with master (or other whatever branch is needed is a proper way to be up to date)
Upvotes: 2
Reputation: 99274
It's perfectly fine to do that, basically:
git pull
git fetch origin master
git merge origin/master -m 'master sync'
Upvotes: 1