git状态(什么都不提交,工作目录干净),但是已提交更改 [英] git status (nothing to commit, working directory clean), however with changes commited

查看:246
本文介绍了git状态(什么都不提交,工作目录干净),但是已提交更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了许多与类似主题相关的问题,但是我没有找到有关此问题的任何实用指南:为什么git status通知我nothing to commit, working directory clean,即使我在本地分支机构进行了修改也很困难?

I found many questions with similar subject, but I didn't found any practical guidance about this issue: why git status informs me nothing to commit, working directory clean, even tough I have made a modification at my local branch?

这是我遵循的步骤:

  • git init [在分支主数据库上-初始提交,没有要提交的内容(创建/复制文件并使用"git add"进行跟踪)]
  • git remote add https://github.com/username/project.git
  • git pull origin master
  • touch test
  • git add test
  • git commit -m "Adding file for test purposes only."
  • git status [在分支主服务器上-无需提交,工作目录干净]
  • git init [On branch master - Initial commit, nothing to commit (create/copy files and use "git add" to track)]
  • git remote add https://github.com/username/project.git
  • git pull origin master
  • touch test
  • git add test
  • git commit -m "Adding file for test purposes only."
  • git status [On branch master - nothing to commit, working directory clean]

如果我执行git push,则修改将提交给远程分支.我只想在修改后执行"git status",并收到我在本地分支上所做的更改的信息,这些更改必须推送到项目的远程分支.

If I do a git push, the modification is committed to the remote branch. I just want to perform "git status" after my modifications, and receive the information that I have changes on my local branch that must be pushed to the remote branch of the project.

有人可以告诉我怎么回事吗?请直接说清楚.

Can someone tell me what's going? Straight to the point, please.

预先感谢SO社区!

推荐答案

您的本地分支不了解远程分支.如果您不告诉git您的本地分支机构( master )应该将自己与远程分支机构(在这种情况下为 origin/master )进行比较;那么git status不会告诉您分支与远程分支之间的区别.因此,您应该使用:

Your local branch doensn't know about the remote branch. If you don't tell git that your local branch (master) is supposed to compare itself to the remote counterpart (origin/master in this case); then git status won't tell you the difference between your branch and the remote one. So you should use:

git branch --set-upstream-to origin/master

或带有短选项:

git branch -u origin/master

此选项-setup-upstream-to (或简称为 -u )在git 1.8.0中引入.

This options --set-upstream-to (or -u in short) was introduced in git 1.8.0.

一旦您设置了此选项; git status将显示以下内容:

Once you have set this option; git status will show you something like:

# Your branch is ahead of 'origin/master' by 1 commit.

这篇关于git状态(什么都不提交,工作目录干净),但是已提交更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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