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

后端 未结 2 626
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-02 13:50

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

then published it with git flow feature publish FEATURENAME

<
相关标签:
2条回答
  • 2021-02-02 14:05

    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.

    0 讨论(0)
  • 2021-02-02 14:15

    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.

    0 讨论(0)
提交回复
热议问题