Search code examples
gitgithubversion-control

Put all commits from feature branch on top of master branch


I have a feature branch which was created from master branch with commit-1. After some time status is as:

Feature branch :

Commit-1, commit - A, Commit - B

Master branch :

Commit - 1, Commit - 2, Commit - 3

What is needed

Want to rebase all the changes from feature branch to master branch.

Expected new history :

Commit - 1, Commit - 2, Commit - 3, commit - A, Commit - B

Issue facing

Performed below commands

git checkout feature

git rebase master

There were some conflicts in say file-1, file-2 and auto merging failed. Resolved those conflicts manually and did

git rebase --continue

But it has created a single git commit instead of getting all the history of commits for me.

Can anyone suggest, how to retain the history of commits here?


Solution

  • Got the issue

    I was not doing the git rebase --continue at the right time, order should be

    git checkout feature
    
    
    git rebase master
    

    If there are conflicts, files are shown as both modified

    git status
    

    Find the files which are modified by both, resolve the merge conflict and then do

    git rebase --continue 
    

    Continue doing the same for all the commits in the feature branch and when all commits are done, it will finish rebasing.