Git:查看我的最后一次提交

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2231546/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 07:49:31  来源:igfitidea点击:

Git: See my last commit

git

提问by Dan Rosenstark

I just want to see the files that were committed in the last commit exactly as I saw the list when I did git commit. Unfortunately searching for

我只想看到在上次提交中提交的文件,就像我在做的时候看到的列表一样git commit。不幸地寻找

git "last commit" log

in Google gets me nowhere. And

在谷歌让我无处可去。和

git diff HEAD^..HEAD

is not what I need, of course, since it spews the guts of the change too.

当然,这不是我需要的,因为它也激发了变革的勇气。

采纳答案by Mike Seplowitz

As determined via comments, it appears that the OP is looking for

根据评论确定,OP 似乎正在寻找

$ git log --name-status HEAD^..HEAD

This is also very close to the output you'd get from svn statusor svn log -v, which many people coming from subversion to git are familiar with.

这也非常接近您从svn statusor获得的输出svn log -v,许多从 subversion 转为 git 的人都熟悉它。

--name-statusis the key here; as noted by other folks in this question, you can use git log -1, git show, and git diffto get the same sort of output. Personally, I tend to use git show <rev>when looking at individual revisions.

--name-status是这里的关键;因为在这个问题其他人指出的那样,你可以使用git log -1git show以及git diff获得相同类型的输出。就个人而言,我倾向于git show <rev>在查看个别修订时使用。

回答by Greg Hewgill

Use git show:

使用git 显示

git show --summary

This will show the names of created or removed files, but not the names of changedfiles. The git showcommand supports a wide variety of output formats that show various types of information about commits.

这将显示已创建或已删除文件的名称,但不会显示已更改文件的名称。该git show命令支持多种输出格式,显示有关提交的各种类型的信息。

回答by knittl

git log -1 --stat

could work

可以工作

回答by Ahmed Al Bermawy

To see last commit

查看上次提交

git log -1

To see last 2 commit

查看最后 2 次提交

git log -2

etc....

等等....

回答by nickhar

By far the simplest command for this is:

到目前为止,最简单的命令是:

git show --name-only

As it lists justthe files in the last commit and doesn't give you the entire guts

由于它列出只是在最后的文件提交,不给你整胆

An example of the output being:

输出的一个例子是:

commit  fkh889hiuhb069e44254b4925d2b580a602
Author: Kylo Ren <[email protected]>
Date:   Sat May 4 16:50:32 2168 -0700

Changed shield frequencies to prevent Millennium Falcon landing

 www/controllers/landing_ba_controller.js             
 www/controllers/landing_b_controller.js            
 www/controllers/landing_bp_controller.js          
 www/controllers/landing_h_controller.js          
 www/controllers/landing_w_controller.js  
 www/htdocs/robots.txt                        
 www/htdocs/templates/shields_FAQ.html       

回答by micrub

git log -1 --name-status

Does the work for me.

对我有用。

回答by shubham mishra

To see last commit changes

查看上次提交更改

git show HEAD

Or to see second last commit changes

或者查看倒数第二次提交更改

git show HEAD~1

And for further just replace '1' in above with the required commit sequence number.

为了进一步,只需将上面的“1”替换为所需的提交序列号。

回答by Mithilesh Tipkari

After you do several commits or clone/pull a repository, you might want to see what commits have been made. Just check these simple solutions to see your commit history (from last/recent commit to the first one).

在您进行多次提交或克隆/拉取存储库后,您可能想查看已进行的提交。只需检查这些简单的解决方案即可查看您的提交历史记录(从上次/最近提交到第一个提交)。

For the last commit, just fire this command: git log -1. For more interesting things see below -

在过去的提交,只触发此命令:git log -1。更多有趣的事情见下文——

  1. To see the commit ID (SHA-1 checksum), Author name <mail ID>, Date along with time, and commit message -

    git log
    
  2. To see some more stats, such as the names of all the files changed during that commit and number of insertions/deletions. This comes in very handy while reviewing the code -

    git log --stat
    
  3. To see commit histories in some pretty formats :) (This is followed by some prebuild options)-

    • If you have too many commits to review, this command will show them in a neat single line:

      git log --pretty=oneline
      
    • To see short, medium, full, or even more details of your commit, use following, respectively -

      git log --pretty=short
      git log --pretty=medium
      git log --pretty=full
      git log --pretty=fuller
      
  4. You can even use your own output format using the formatoption -

    git log --pretty=format:"%an, %ae - %s"
    

    where %an - author name, %ae - author email, %s - subject of commit, etc.

  1. 要查看提交 ID(SHA-1 校验和)、作者姓名 <邮件 ID>、日期和时间以及提交消息 -

    git log
    
  2. 要查看更多统计信息,例如在该提交期间更改的所有文件的名称以及插入/删除的数量。这在代码时非常方便 -

    git log --stat
    
  3. 以一些漂亮的格式查看提交历史:)(后面是一些预构建选项)-

    • 如果你有太多的提交需要,这个命令会将它们显示在一个整洁的单行中:

      git log --pretty=oneline
      
    • 要查看提交的简短、中等、完整甚至更多详细信息,请分别使用以下内容 -

      git log --pretty=short
      git log --pretty=medium
      git log --pretty=full
      git log --pretty=fuller
      
  4. 您甚至可以使用format选项使用自己的输出格式-

    git log --pretty=format:"%an, %ae - %s"
    

    其中 %an - 作者姓名,%ae - 作者电子邮件,%s - 提交主题等。

This can help you with your commit histories. For more information, click here.

这可以帮助您处理提交历史记录。如需更多信息,请单击此处

回答by Greg Bacon

$ git diff --name-only HEAD^..HEAD

or

或者

$ git log --name-only HEAD^..HEAD

回答by andy magoon

git diff --stat HEAD

git diff --stat HEAD

This shows the same diffstat as your last commit.

这显示了与您上次提交相同的 diffstat。