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?
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).
If 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