I am setting my local branch to track remote branch like this:
$ git branch --set-upstream foo upstream/foo
But when I do git status, I get:
$ git status
# On branch foo
# Your branch and 'upstream/foo' have diverged,
# and have 108 and 43 different commits each, respectively.
What can I do to fix my local branch so that it no longer diverged with remote branch?
One idea I have is to delete my local branch and recreate another branch to track the same remote branch. Is there another way
You have two divergent lines of development. You have two choices:
The first option is easy. Deleting your local branch and then checkout out a new local copy of the remote branch will accomplish this. You could also:
The second option may require you to manually correct merge conflicts. In theory, simply running:
Should perform the merge, leaving you to clean up any conflicts.