I’ve been reading and re-reading the post about a successful git model (git flow) and I’m confused about a couple things when working off a develop branch. He says:
When starting work on a new feature, branch off from the develop branch.
$ git checkout -b myfeature develop
- What branch is he starting in? My checked out ‘develop’ branch?
- Is the ‘develop’ after ‘myfeature’ track my local ‘develop’ branch or the remote ‘origin/develop’ branch?
- If I start in my ‘develop’ branch when I create ‘myfeature’ do I need the ‘develop’ at the end?
- Does ‘myfeature’ copy the current HEAD of the develop branch?
- If I only wanted to see my changes on a dev server, do I need to merge into my local develop or remote develop?
I’m trying to wrap my head around it – off to re-read it again and find some screencasts based on this model.
Doesn’t matter, because he explicitly set the base commit (
develop). After the command is run, he’ll be on themyfeaturebranch, regardless of what was checked out before.developis a local branch that probably tracksorigin/develop, your remote tracking branch.Nope.
git checkout -b myfeature, without an explicit starting point, will create a new branch at yourHEAD. If you’re at the tip of thedevelopbranch,myfeaturewill be based ondevelop.Not exactly.
myfeaturereferences the same commit that the tip ofdevelopreferences. Nothing is "copied". When you commit changes whilemyfeatureis checked out, themyfeaturetip will be updated to the new commits.developwill not change.If you want to see your changes at a remote location, you need to push to the remote location. Just merging into a local branch won’t do anything for the remote side.
If you want to "finish" your feature, git-flow-style, I’m guessing you want the Incorporating a finished feature on develop section: Switch to
develop, merge inmyfeature, deletemyfeature, and push the now-updateddevelopout toorigin.[e] More answers:
The new branch starts from
developin both cases. (git branchworks the same way, except it won’t switch you to the new branch likegit checkout -bdoes.)Roughly, though
git push originis not always "aka origin/develop". By defaultgit push originwill push all the local branches that have the same name (or have been set up to track) the branches on origin. (You can change the default with thepush.defaultconfig setting.)git push origin developwill push just your local develop branch to origin’s develop branch, which is what you want.Only if you force the push (which, seriously, don’t do that). You can do the pull after the merge, but then you’d essentially be merging twice. It works out better to do the pull first, but you’re not at risk of losing data if you don’t.
Sure, if someone else has pushed out updates to
origin/developand you want to incorporate their changes. Essentially, you would mergedevelopintomyfeatureif you want to keep your feature branch current and you’re not ready to merge intodevelop.In the git-flow system,
myfeatureshould always go back todevelop, and release branches always start fromdevelop.developis supposed to be the branch for changes ready for external exposure–for integration testing, release candidates, whatever–as well as the branch that represents the current state of development in the project. It’s the starting point for all the new stuff. You don’t want to end up with your work in themyfeaturebranch and some random release branch, but not the maindevelopline.