Why doesn't “git flow feature pull” track?

本小妞迷上赌 提交于 2019-12-03 07:58:47

问题


Lets say I've created a new feature with git flow feature start FEATURENAME

then published it with git flow feature publish FEATURENAME

Now my colleague wants to collaborate on this feature with me, so he does

git flow feature pull FEATURENAME

This creates a new branch on his local repo, based on the feature branch in the remote repo. This does not however set his local feature branch to track the remote feature branch, so now he has to track this branch manually.

What is the reasoning behind this extra step? Why not have the feature pull command set to track as well?

What's the workflow difference between git flow feature pull and git flow feature track.

In which cases would you use each of those?


回答1:


Sounds like you are using git flow feature pull, where you should be using git flow feature track, since that does create a local branch that tracks the remote.

I can't really think of why I'd ever use git flow feature pull. It creates a local branch with no tracking set up on it, and I don't know why that would be useful! It's also badly named, since a pull should involve a merge, and this does not.




回答2:


This answer by brainimus illustrates the collaborative aspect of a feature branch, using the GitHub pull request aspect which facilitates the code review and discussion part:

  1. Create a feature branch: git flow feature start module_1
  2. The code is updated on the feature branch
  3. As changes are committed they are pushed to GitHub (or once at the end if preferred)
  4. When the feature is completed a pull request is opened in GitHub comparing develop and the feature branch module_1
  5. The team reviews the pull request and makes comments
  6. Any changes from the pull request are made to the feature branch
  7. Once all changes are incorporated on the feature branch the feature branch is finished: git flow feature finish module_1
  8. The develop branch is pushed to GitHub (GitHub will automatically mark the pull request as closed/merged when this happens)

That leaves the issue of closing that branch though:

Who ever runs git flow feature finish module_1 will have the luxury of their local feature branch being deleted but anyone else who checked out the branch with have to do this manually if they want to

I would recommend a git fetch --prune, especially since Git 1.8.5 you can set that "prune" step in your config: a simple git fetch will remove your feature branch if it has been deleted on the server side (by someone else making a git flow feature finish)


The gitflow feature track if the AVH edition simply checkout and track the branch, that is make sure the local branch becomes a local tracking branch, with an upstream branch (a remote tracking branch) associated to it.
That is, it sets up branch.<name>.remote and branch.<name>.merge.

If you do a git flow feature pull (for a new local feature branch), but meant actually git flow feature track, all you would need to do would be to make your existing branch track the upstream one:

git branch -u origin/feature

Generally:

  • you start with git flow feature track,
  • then you keep your local feature branch up-to-date with git flow feature pull
  • you switch between feature branches with git flow feature checkout

As mention in "Getting Started – Git-Flow":

git flow feature pull

This will be done when more than one person works on a feature together.
You should use this command if you want to do a pull on the remote feature branch as follows:

git flow feature pull [alias] [featureName]

By using this command you’ll get the source code that has been pushed by your team mates and their changes will be automatically merged into your local branch.
If there are conflicts you will be the unlucky or lucky one to do the resolutions of these conflicts.



来源:https://stackoverflow.com/questions/18412750/why-doesnt-git-flow-feature-pull-track

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!