Search code examples
gitgithubgit-rebase

What I should do when using Gitflow Workflow and the master progress?


I've read about Gitflow Workflow here and they say to create a develop branch from master and a feature branch from develop. So I forked a repo and I created a branch develop having the latest commit on master (C1) as parent, then I created two features branches from develop branch where I'm working. Now master has new commits but my develop branch and features branches are still based on the older commit(C1).

There is a way to integrate changes as master progress, like changing where is pointing the develop branch? Maybe using rebase but I don't know how to apply to my case. develop and features branches are local.

In few words how to work on a feature and constantly integrate the progress from master?


Solution

  • To keep your branches in sync with master you basically will need to this:

    First, change to master branch and get the changes:

    git checkout master
    git pull
    

    Then change to your branch and put it in sync with master:

    git checkout your-branch
    git merge master
    

    Depending on what you are working on it may create some conflicts while merging the ones you will have to solve.

    In case you don't want to update first your local master branch you can update directly your local branch with the <remote>/master by doing this:

    git checkout your-branch
    git rebase origin/master 
    

    You could also push directly from your branch to master:

    git push origin HEAD:master
    

    But will not play nice with the gitflow, better push to develop, etc.