Update an outdated branch against master in a Git repo

I have a Git repository that has branch (local and remote) that has become outdated. I would like to bring this branch up to date with the master branch, but I don’t know how to do this. There will also probably be many merge conflicts.

How can I bring or update this out-of-date branch to the same state as the master branch?

  • git-subtree stable for repos with lots & deeply nested subtrees?
  • How to see that Jenkins polled a Git repo
  • Change the location where git looks for its dependency
  • How to find latest non-merge commit message in Git?
  • Add another fork in github. Do not merging. It is a parallel project
  • Latest Jenkins not cloning submodule
  • Which files or commits does Git consider when calculating differences for cherry-pick, merge and rebase?
  • How do I publish to <me>.github.com?
  • EGit refactor rename project NOT renames git working tree folder
  • Merging a branch of a branch after first branch is squashed when merged to master
  • private-bower : git cache?
  • Accidentally merged in wrong branch to mine. Is there a way to remove these unwanted files?
  • One Solution collect form web for “Update an outdated branch against master in a Git repo”

    Update the master branch, which you need to do regardless.

    Then, one of:

    1. Rebase the old branch against the master branch. Solve the merge conflicts during rebase, and the result will be an up-to-date branch that merges cleanly against master.

    2. Merge your branch into master, and resolve the merge conflicts.

    3. Merge master into your branch, and resolve the merge conflicts. Then, merging from your branch into master should be clean.

    None of these is better than the other, they just have different trade-off patterns.

    I would use the rebase approach, which gives cleaner overall results to later readers, in my opinion, but that is nothing aside from personal taste.

    To rebase and keep the branch you would:

    git checkout <branch> && git rebase <target>
    

    In your case, check out the old branch, then

    git rebase master 
    

    to get it rebuilt against master.

    Git Baby is a git and github fan, let's start git clone.