git - what is the best practice for team work on a feature branch?

branching-and-merging, git

Solution

I assume you follow this model: http://nvie.com/posts/a-successful-git-branching-model/

I think most of the demonstrated commands are correct, you can however make things easier by implementing git alliasses

Problem

We have the following branches: `master` and `develop`. We created a new branch `feature` off of `develop` and assigned a team to work on it. During development: - remote `develop` accepts new commits by other teams. - remote `feature` accepts new commits pushed by the team members working on it. Sometimes there are hot fixes pushed to `develop` that need to be updated in `feature` as well. Of course, at the end of the cycle, `feature` should be merged into `develop`. We don't have a single workflow to keeping `feature` and it's local copies in sync with `develop`, and then making sure all local copies are based on the same commit. My suggested workflow is as follows: Keeping up-to-date with `develop` - New commits are pushed to `develop` I rebase the `feature` branch: ``` git checkout feature git pull --rebase origin develop git push origin feature ``` All local `feature` copies run: `git pull --rebase origin feature` Updating the `feature` branch from local copies - A team member has finished his work on the `feature` branch - He makes sure his local copy is up to date: `git pull --rebase origin feature` He merges his commits into `feature`: ``` git checkout feature git pull origin feature git merge local-feature git push origin feature ``` Merging the `feature` branch into `develop` I make sure feature is up to date with `develop`: ``` git checkout feature git pull --rebase origin develop ``` I merge into `develop`: ``` git checkout develop git pull origin develop git merge feature git push origin develop ``` We do all that `pull --rebase` stuff in order to keep linear flow and make sure all our changes are merged using fast-forward. However, as you can tell, there are a lot of commands to run every time. Is this really necessary? Are we doing it the "right" way? Would you suggest another flow?

Original source