Backlog uses cookies to deliver our services. By visiting our website, you agree to the use of cookies as described in our Cookie Policy.

Another approach we can take to integrate "issue3" branch into the master branch is by using the rebase command. Using rebase, we can streamline and clean our history tree just like how we have described earlier.

Let's start by undoing the previous merge.

$ git reset --hard HEAD~
History before rebase

Switch over to "issue3" branch and rebase onto the master branch.

$ git checkout issue3
Switched to branch 'issue3'
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: append description of the pull command
Using index info to reconstruct a base tree...
:13: new blank line at EOF.
warning: 1 line adds whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging myfile.txt
CONFLICT (content): Merge conflict in myfile.txt
Failed to merge in the changes.
Patch failed at 0001 append description of the pull command

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To check out the original branch and stop rebasing run "git rebase --abort".

When a conflict occurs during the rebase, you will have to resolve it immediately in order to resume the rebase operation.

Git commands even a monkey can understand
add: Register a change in an index
<<<<<<< HEAD
commit: Save the status of an index
pull: Obtain the content of a remote repository
>>>>>>> issue3

Once the conflict is resolved, you can resume rebase with the --continue option. If you wish to quit and rollback the rebase operation, you can do so by passing in the --abort option.

$ git add myfile.txt
$ git rebase --continue
Applying: append description of the pull command
Current history

With the "issue3" branch rebased onto "master", we can now issue a fast-forward merge.

Switch over to the master branch and merge "issue3" with "master".

$ git checkout master
Switched to branch 'master'
$ git merge issue3
Updating 8f7aa27..96a0ff0
myfile.txt | 1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

The content of myfile.txt should now be identical to the one that we got from the previous merge. The revision history now should look like the following.

Current history