git status(没有提交,工作目录干净),但是更改提交 [英] git status (nothing to commit, working directory clean), however wth changes commited

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

问题描述

我发现了很多类似主题的问题,但是我没有发现任何有关此问题的实用指南:为什么 git status 通知我提交,工作目录干净,甚至很难我已经在我的本地分支进行了修改?



以下是我遵循的步骤: p>


  • git init [On branch master - 初始提交,不需要提交(create / copy文件并使用git add跟踪)]

  • git remote add https://github.com/username/project.git

  • git pull origin master

  • touch test
  • code>
  • git add test

  • git提交-m添加文件仅用于测试目的。

  • git status 没有提交,工作目录干净]



如果我做一个 git push ,修改被提交给远程分支。我只想在修改后执行git status,并接收我在本地分支上发生的必须推送到项目远程分支的信息。



<有人可以告诉我发生了什么事吗?直接点,请:()。



感谢提前SO社区!

解决方案如果你不告诉git你的本地分支( master )应该将它自己与远程分支进行比较(

> origin / master );然后git status不会告诉你分支和远程分支之间的区别,所以你应该使用:

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

或使用简短选项:

  git branch -u origin / master 

这个选项 - set-upstream-to (简称 -u )是在git 1.8.0。



一旦你设置了这个选项, git status 会显示如下内容:

 #您的分支在1次提交之前领先于'origin / master'。


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?

Here are the steps which I followed:

  • 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]

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 :(.

Thanks in advance SO community!

解决方案

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

or with the short option:

git branch -u origin/master

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

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

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

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

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