Reputation: 419
We have the main branches develop
, release
and master
in Bitbucket. develop
branch is for current development. Team creates feature
branches from develop
and they will merge a feature
branch with develop
once code changes are done.
In some case, if we find a bug, we have to rollback some particular change which is deployed in UAT
. So we will create a bugfix
branch from release
, rollback the change and merge with release
and develop
as well. But some developers might already have started working for the next sprint on newly created feature
branches. To rollback the same from feature
branch, what is the best practice when many people work on the same repository?
Since the team is working with Sourcetree client instead of command line, it would be helpful if someone could advise how it should be done on Sourcetree.
Upvotes: 0
Views: 1917
Reputation: 38116
To make feature
branch works on the latest develop
branch (rollback changes from feature branch), you can rebase feature
branch changes when pulling develop
branch.
Detail steps as: checkout feature branch in source tree -> pull -> select develop
for Remote branch to pull -> select Rebase instead of merge
for Options.
Note:
If there has conflicts during rebase, you need to manually solve the conflicts and then use the commands git add .
and git rebase --continue
one by one, especially when you have many commits on feature branch. Or you can use the command git pull origin develop --rebase -X ours
to auto solve the conflict files by keeping the version from latest develop
branch on remote.
Illustrate by graphs:
E---F feature(HEAD)
/
A---B---C---D develop
There has new commit G
on develop
branch from remote:
E---F feature(HEAD)
/
A---B---C---D---G origin/develop
|
develop
After use git pull origin develop --rebase
:
E---F feature(HEAD)
/
A---B---C---D---G origin/develop
Upvotes: 1
Reputation: 2853
It is good practice to regularly either rebase your feature branches onto develop, or merge from develop into your feature branches.
Imagine a live bug that blocks a developer from working on his feature. The hotfix is released and merged into develop
. Of course the fix should not be copy/pasted into the feature branch, the hotfix commit should be pulled (either by merge or rebase) from develop
into the feature
branch so the developer can continue working in the context of what is currently stable in develop
.
The decision of whether to rebase or merge is for you to decide - either is a valid choice. There is plenty of discussion regarding the pros and cons of both workflows. For example: https://www.atlassian.com/git/articles/git-team-workflows-merge-or-rebase
To rebase in Sourcetree: With the feature branch checked out, right click on the dev branch and click rebase. To be able to push these changes you will need to tick the Force push option which must first be enabled in Tools>Options, Git, Enable Force Push.
Note that if there are conflicts during the rebase, you'll need to resolve them and then continue the rebase from the Actions menu.
Upvotes: 1
Reputation: 38724
I guess the feature branches are only local branches of the developers? So just make your developers regularly rebase their feature branches against develop
branch, then they are sure to have their work based on the latest changes on develop
, including such rollbacks.
Upvotes: 1