How to stop divergent branch warnings in Git?

I use git flow so I work on a develop branch and only push releases to master . After creating a remote (named heroku ) on my Heroku account, I started pushing my local develop branch to master , mostly for verification:

 git push heroku develop:master

Now that my app is more mature, I only push master releases. However, Git indicates that my local develop branch and the remote master branch have diverged:

Your branch and 'heroku/master' have diverged,
and have 1 and 11 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

How can I stop these warnings without merging the remote master branch into the local develop branch?


In order to stop the warnings, you need to stop your local develop branch from tracking the remote master branch.

To remove the association between your local and remote branch:

git config --unset branch.develop.remote
git config --unset branch.develop.merge

This should stop the warnings.


I've been feebly trying to remove the merged commits directly on the heroku remote. However, the problem is that the local develop branch was set to track the remote master branch when I first pushed it:

% git remote show heroku
* remote heroku
  Fetch URL: [REDACTED]
  Push  URL: [REDACTED]
  HEAD branch: master
  Remote branch:
    master tracked
  Local branches configured for 'git pull':
    develop merges with remote master
    master  merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)

So all I needed to do was to have the local develop branch stop tracking the remote branch. Following this answer, I removed the tracking branch and unset it as upstream:

# On branch develop
% git branch -d -r heroku/master
% git branch --unset-upstream
链接地址: http://www.djcxy.com/p/26108.html

上一篇: 在两个Git仓库之间同步单个文件

下一篇: 如何在Git中停止发散分支警告?