Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a branch for a new feature on local branch only or on both local and remote branches?

I follow this tutorial : gitflow

Normally, when I implement a new feature, I create a new branch (only for local), after I finish my changes, I pull the develop branch, merge with my local branch and push back to develop


git checkout -b new-feature

git add .
git commit -m "finish the new feature"

git pull origin develop
git checkout develop
git merge new-feature
git push

However, my colleague create a remote branch (branch off from the develop branch). When he finishes with the new feature, he merge with the develop branch.

So, I am wrong or he is wrong? Or both of us are correct?

like image 664
chipbk10 Avatar asked Nov 17 '15 14:11

chipbk10


1 Answers

You both are correct.

I'll create a local branch for a feature if I'm the only one that needs to work on it. If multiple developers need to work on a feature, creating and pushing that branch to the remote via git push origin -u feature_branch is the best way.

Another upside to pushing your local branch to the remote is that you've got a backup of your work on another computer in case yours crashes. I rarely do this since I git rebase as I work locally, and changing public Git history is a no-no (it orphans anyone else who has pulled down and tracked your branch).

like image 186
Greg Burghardt Avatar answered Oct 22 '22 05:10

Greg Burghardt