如何查看上次提交中更改的文件

时间:2018-04-16 08:50:06

标签: git

在此提交消息中,它表示已更改了2个文件。

$ git commit -m "fixed .gitignore"
[master c30afbe] fixed .gitignore
 Committer: Sahand Zarrinkoub <sahandzarrinkoub@n133-p41.eduroam.kth.se>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 2 files changed, 5 insertions(+), 4 deletions(-)

这对我来说有点意外。我以为我只会上传一个文件进行更改。现在,我想看看哪些文件已被更改以及如何更改。这样做的方法是什么?

6 个答案:

答案 0 :(得分:7)

除了Nitin Bisht的答案,您还可以使用以下内容:

git log -1 --stat --oneline

它将显示有关最近一次提交中更改了哪些文件的简要信息。自然地,可以通过指定任意数量的提交来代替“ -1”,以显示上一次“ -n”提交中更改的文件。

您还可以跳过通过“ --no-merges”标志的合并提交:

git log -1 --stat --oneline --no-merges

答案 1 :(得分:1)

您可以使用 git log --stat

此处 - stat 将包含已修改文件的名称和路径,以及每个文件中受影响的行数。

答案 2 :(得分:1)

获取自上次提交以来所有更改的文件

def scale_box(self, screen, text):

    max_length = 10
    nb_lines = len(text) // max_length + (1 if len(text) % max_length > 0 else 0)
    lines = []
    for i in range(nb_lines):
        linetext = text[i*max_length : (i+1)*max_length]
        lines.append( self.box_font.render(linetext, True, self.font_color) )

    width = max([l.get_width() for l in lines])
    height = sum([l.get_height() for l in lines])
    y = self.box.y - nb_lines * self.coords[3]
    self.box = pygame.Rect(self.box.x, y, width, height)

    y = self.box.y
    for l in lines:
        screen.blit(l, (self.box.x + 10, y))  
        y += l.get_height() 

答案 3 :(得分:0)

git log  // this will give you the hash-code 
git show hash-code   

答案 4 :(得分:0)

add_filter('get_pagenum_link', 'edit_paginate_url'); function edit_paginate_url($url){ $pagenum = preg_match("/\/\d\//", $url, $pagenum); $pagenum = preg_replace("/\//", "", $pagenum); $url = preg_replace("/\/page\/\d/", "?page=", $url); return $url . $pagenum; }

答案 5 :(得分:0)

您可以通过多种方式完成此操作。这是我在没有查看文档的情况下提出的。

$ git log -1 --name-only

commit 3c60430b752bca26bd3c80604df87ffb2ae358 (HEAD -> master, origin/master, origin/HEAD)
Author: Name Surname <name.surname@email.com>
Date:   Mon Apr 2 18:17:25 2018 +0200

    Example commit

.gitignore
README
src/main.c

或者:

$ git log -1 --name-only --oneline

commit 3c60430 (HEAD -> master, origin/master, origin/HEAD) Example commit
.gitignore
README
src/main.c

或者:

$ git log -1 --stat --oneline

commit 3c60430 (HEAD -> master, origin/master, origin/HEAD) Example commit
.gitignore |  2 ++
README     |  8 ++++++++
src/main.c | 12 ++++++++++++
3 files changed, 22 insertions(+)