zerkms
zerkms

Reputation: 254916

Is there a way to remove "diverged" message in git?

I accidentally pressed enter before I had to which resulted to executing

git checkout

in some local branch.

Now on git status that's what is shown:

# On branch <branchname>
# Your branch and 'origin/master' have diverged,
# and have 2 and 329 different commits each, respectively.
#   (use "git pull" to merge the remote branch into yours)
#
nothing to commit, working directory clean

Is there any easy way to stop this message from showing?

PS: I don't want to merge yet

Upvotes: 0

Views: 100

Answers (2)

Koraktor
Koraktor

Reputation: 42903

git branch --unset-upstream

This will stop tracking origin/master on the current branch and thus cause the message to disappear. But you might be more interested in an integral solution as provided by @poke.

Upvotes: 3

poke
poke

Reputation: 387587

Your best option to “get rid” of it would be to work on a separate branch instead of master. This allows you to continue your work however you want, while maintaining a non-diverged branch on your local master itself.

To do that, just call git checkout -b newBranchName and you will automatically create a new branch with the current history and switch to it. Afterwards, you could even clean up your local master to “get back” to the master-only history by calling git checkout master and then git reset --hard origin/master. Note that you should make sure that your working directory is clean first and that your new branch really carries all the history.

Upvotes: 1

Related Questions