git出错"Your branch is ahead of 'origin/LS3A_2H' by 4 commits"解决

当运行命令

git status

后,出现这种log信息,之后修改程序push时会出错,所以在出现这种信息时就需要进行sync修改。

$ git status
On branch LS3A_2H
Your branch is ahead of 'origin/LS3A_2H' by 4 commits.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean

解决方法:

$ git fetch origin
From ssh://10.2.5.33:29418/WindRiver
   60f0a02..eb02e64  LS3A_2H    -> origin/LS3A_2H
验证:

$ git status
On branch LS3A_2H
Your branch is up-to-date with 'origin/LS3A_2H'.
nothing to commit, working directory clean


解决方式2:

baz@bhost:/more/coding/git-tests$ git clone https://shishani@bitbucket.org/shishani/dirasi.git ask1
Cloning into ask1...
Password: 
remote: Counting objects: 24054, done.
remote: Compressing objects: 100% (6300/6300), done.
remote: Total 24054 (delta 17124), reused 24024 (delta 17106)
Receiving objects: 100% (24054/24054), 11.83 MiB | 251 KiB/s, done.
Resolving deltas: 100% (17124/17124), done.


baz@bhost:/more/coding/git-tests$ cd ask1


baz@bhost:/more/coding/git-tests/ask1$ jed setup.py


baz@bhost:/more/coding/git-tests/ask1$ git commit -a
[master a053f28]    modified:   setup.py
 1 files changed, 1 insertions(+), 0 deletions(-)


baz@bhost:/more/coding/git-tests/ask1$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)


baz@bhost:/more/coding/git-tests/ask1$ git remote show origin
Password: 
* remote origin
  Fetch URL: https://shishani@bitbucket.org/shishani/dirasi.git
  Push  URL: https://shishani@bitbucket.org/shishani/dirasi.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (fast-forwardable)



baz@bhost:/more/coding/git-tests/ask1$ git push
Password: 
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 314 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: bb/acl: shishani is allowed. accepted payload.
To https://shishani@bitbucket.org/shishani/dirasi.git
   5e9ffd1..a053f28  master -> master


baz@bhost:/more/coding/git-tests/ask1$ git status
# On branch master
nothing to commit (working directory clean)




baz@bhost:/more/coding/git-tests/ask1$ jed setup.py

baz@bhost:/more/coding/git-tests/ask1$ git commit -a
[master 6d0e236]    modified:   setup.py
 1 files changed, 1 insertions(+), 0 deletions(-)


baz@bhost:/more/coding/git-tests/ask1$ git push https://shishani@bitbucket.org/shishani/dirasi.git master
Password: 
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 298 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: bb/acl: shishani is allowed. accepted payload.
To https://shishani@bitbucket.org/shishani/dirasi.git
   a053f28..6d0e236  master -> master


baz@bhost:/more/coding/git-tests/ask1$ git status
# On branch master
**# Your branch is ahead of 'origin/master' by 1 commit.** <-- this does not reflect current state
#
nothing to commit (working directory clean)


baz@bhost:/more/coding/git-tests/ask1$ git push
Password: 
Everything up-to-date


baz@bhost:/more/coding/git-tests/ask1$ git status
# On branch master
nothing to commit (working directory clean)

解决方式3:

wh-test $ git branch -a
alternate
* cherryPick
  master
  new
  squashBranch
  testBranch
  remotes/origin/HEAD -> origin/master
  remotes/origin/cherryPick
  remotes/origin/master
  remotes/origin/testBranch

wh-test $ git status
# On branch cherryPick
# Your branch is ahead of 'origin/cherryPick' by 1 commit.
#

wh-test $ git pull origin cherryPick
From ssh://xxxx.dyndns.org/home/shopapp/wh-test
 * branch            cherryPick -> FETCH_HEAD
Already up-to-date.




  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值