git:你的分支在X提交之前 [英] git: Your branch is ahead by X commits

查看:128
本文介绍了git:你的分支在X提交之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我现在正在自己的一个仓库中工作,所以这是我的工作流程:


  1. 更改文件
  2. 提交

  3. 重复1-2直到满意

  4. 推送给master

然后当我执行 git status 它告诉我,我的分支由X提交提前(推测可能与我提交的提交数相同)。是因为当你推动代码时,它实际上并没有更新你的本地缓存文件(在.git文件夹中)? git pull 似乎是'修复'这个奇怪的消息,但我仍然好奇它为什么会发生,也许我使用git错误?







包括在邮件中打印什么分支

我的本​​地分支在主分支之前


您在哪里推/拉当前分支

我正在推送GitHub,并将其拉到那个时候我碰巧正在处理的计算机上,我的本地副本始终完全保持最新,因为我是只有一个工作。


它实际上不检查远程回购


这就是我的想法,我认为我会确保我的理解是正确的。


<


不是我能看到的东西,也许有一些有趣的配置正在运行n在我的最后?

  $ git status 
#在分支大师
#你的分支领先于'origin / master'由1提交。
$
没有提交(工作目录干净)


解决方案

如果您在执行 git pull remote branch 后收到此消息,请尝试使用 git fetch 。 (或者,运行 git fetch -p 来修剪已删除的分支)



Fetch似乎更新本地远程分支的表示,当您执行 git pull remote branch 时不一定发生。


How does this actually come about?

I am working in one repo by myself at the moment, so this is my workflow:

  1. Change files
  2. Commit
  3. Repeat 1-2 until satisfied
  4. Push to master

Then when I do a git status it tells me that my branch is ahead by X commits (presumably the same number of commits that I have made). Is it because when you push the code it doesn't actually update your locally cached files (in the .git folders)? git pull seems to 'fix' this strange message, but I am still curious why it happens, maybe I am using git wrong?


including what branch is printed in the message

My local branch is ahead of master

where do you push/pull the current branch

I am pushing to GitHub and pulling to whichever computer I happen to be working on at that point in time, my local copy is always fully up to date as I am the only one working on it.

it doesn't actually check the remote repo

That is what I thought, I figured that I would make sure my understanding of it was correct.

are you passing some extra arguments to it?

Not ones that I can see, maybe there is some funny config going on on my end?

$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)

解决方案

If you get this message after doing a git pull remote branch, try following it up with a git fetch. (Optionally, run git fetch -p to prune deleted branches from the repo)

Fetch seems to update the local representation of the remote branch, which doesn't necessarily happen when you do a git pull remote branch.

这篇关于git:你的分支在X提交之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆