如何检查我要提交的内容?

时间:2014-03-26 08:59:26

标签: git github

我正在使用Git进行一些功能开发。在这之间,我遇到了一些紧急错误,因此需要从develop branch开启feature/2.8.0。所以要做到这一点,我运行以下命令(来自shell历史):

 2002  git status 
 2003  git stash 
 2004  git checkout develop 
 2005  git status 
 2006  git pull
 2007  git pull origin develop

现在这是我的git status

$ git status
# On branch develop
# Your branch is ahead of 'origin/develop' by 1 commit.
#   (use "git push" to publish your local commits)
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   src/lib/eval/prvl_listed_securities_0000_hxx0401_init.erl
#   src/lib/eval/prvl_listed_securities_0000_hxx0401_proc.erl
#   src/view/eval/prvl_listed_securities_0000_hxx0401.html
nothing added to commit but untracked files present (use "git add" to track)

在这里,我可以看到以下几行:

>    # On branch develop
>    # Your branch is ahead of 'origin/develop' by 1 commit.
>    #   (use "git push" to publish your local commits)

从历史来看,我没有做任何事情,我怎样才能检查我的本地提交需要推送什么?

3 个答案:

答案 0 :(得分:2)

这里有两个独立的问题。让我们来谈谈第一个(标题)。

“如何检查我要提交的内容?”

您可以使用services.AddIdentityCore<ApplicationUser>() .AddPasswordValidator<YourCustomValidator>() 查看哪些文件...

  • 您尚未添加(带有git status)。这些是“未跟踪的文件”。
  • 您尚未承诺。这些是运行git add <file> 将要落实的“要落实的更改”。

此示例说明了差异。

git commit

现在让我们谈第二个(最后一个问题)。

“如何检查需要推送的本地提交?”

对于那个,您将要使用<O.o> git status On branch example-branch Untracked files: (use "git add <file>..." to include in what will be committed) exampleFile.txt nothing added to commit but untracked files present (use "git add" to track) <O.o> git add exampleFile.txt <O.o> git status On branch example-branch Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: exampleFile.txt <O.o> git commit -m "touched exampleFile.txt" [example-branch 8a2b990432] touched exampleFile.txt 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 exampleFile.txt <O.o> git status On branch example-branch nothing to commit, working tree clean <O.o> 。如果没有准备提交的更改,则可以安全地省去git diff origin/master HEAD部分。如果您只需要文件列表而不是代码差异,请添加

HEAD 选项。

另请参见以下线程: How can I see what I am about to push with git?

答案 1 :(得分:1)

您可以使用以下语法获取尚未推送到远程分支X的分支origin/X上的所有本地提交的列表:

git log origin/X..X

使用是..是提交范围的示例。您可以在FREE online Pro Git book中详细了解如何使用它们,尤其是commit ranges部分。

答案 2 :(得分:0)

尝试: git show HEAD 这显示了当前头部提交的内容