Search code examples
gitgit-flowgit-tower

How to clean working directory after closing a feature branch put old code into develop


I'm working on a project which uses git-flow, where feature branches have been left dangling. I want to clean things up but I'm not very familiar with git-flow in practice.

I used Tower's git-flow "finish feature" on that branch, then noticed that my working directory now contains code that has been superseded a while ago.

In hindsight, I guess I should have rebased the code on the feature branch to use the latest develop branch available, which I thought git-flow did automatically.

How do I clean this mess (i.e. return my working directory to the latest status of the develop branch) and how do I merge old feature branches without reverting code?

Thanks!


Solution

  • I'm not entirely sure I understood your problem.

    Here's what I got :

    You have a feature branch that you started a while ago, but several changes having been made on develop (master)

    git checkout develop
    git fetch -p
    git pull origin develop (or whatever your main branch is called)
    git checkout myfeaturebranch
    git merge develop
    

    Now some files will be correctly updated, but you'll most likely get conflicts if you touched the same files. The files with conflicts will show, but you can also check them by writing this command

    git status
    

    When you are done fixing the conflicts, just do the normal add and commit commands.