git pull 报错

开源 0

hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:

问题:

aaa@bbb:~/xxx/xxx/xx/xxx$ git status .
On branch cornerstone_security
Your branch and 'origin/dev' have diverged,
and have 3 and 3 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

nothing to commit, working tree clean
aaa@bbb:~/xxx/xxx/xx/xxx$ git pull
hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint:
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
fatal: Need to specify how to reconcile divergent branches.

解决:

aaa@bbb:~/xxx/xxx/xx/xxx$ git pull --rebase origin dev
From ssh://sdv-gerrit.xxx.local:29418/xxx/xxx/xx
 * branch            dev        -> FETCH_HEAD
Successfully rebased and updated refs/heads/xxx.

git pull --rebase origin dev 

上述命令等同于:

git fetch origin

git rebase origin/dev

引用:git Your branch and 'origin/dev' have diverged - SegmentFault 思否

也许您对下面的内容还感兴趣: