从我的Git diff命令中寻找更多信息 [英] Looking for more info from my Git diff command

查看:154
本文介绍了从我的Git diff命令中寻找更多信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的基本 git diff 对我来说并不是很重要。在这里,我将我的主分支与暂存服务器的主分支区分开来:

 (〜/ hbb.vm)debian $ git diff。 .stage / master --name-only 
sites / all / libraries / attachment_email / attachment_email.php
sites / all / modules / redirect / redirect.module
sites / all / modules / redirect /redirect.test
sites / all / themes / HBB / css / elements.css
sites / all / themes / HBB / templates / node - enterprise_blog.tpl.php

我希望看到以下信息:


  • 该文件已被添加/修改/删除?

  • 在哪个分支上文件已被添加/修改/删除?
    $ b

    编辑:我不想看到所有的变化 - 我想要介于两者之间的东西。丰富的摘要。

    解决方案

    您可以使用以下命令来查看当前分支与<$ c
    $ b $ $ g $ diff --name-status ..stage / $ c $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ master
    M practice.txt
    shazbot.txt
    D foobar.txt

    其中 M 代表Modified, A 代表Added, D 代表已删除。



    如果您想在 / strong>这些文件已被修改,添加或删除,您可以使用 log 命令,而使用相同的 - name-status 参数:

      $ git log --oneline --name-status ..stage / master 
    31b9628添加shazbot.txt
    a shazbot.txt
    e56da37合并分支'develop'
    790f3bf恢复恢复合并分支'develop'
    M practice.txt
    d9493e0合并分支'master'into develop
    8832960恢复合并分支开发'
    M practice.txt
    2b82909合并分支'develop'
    2d41fb6修复bug 01
    M练习.txt
    526bf16添加功能02
    M practice.txt
    ba8700c添加功能01
    M practice.txt
    bb8ced2添加practice.txt
    练习。 txt

    询问提交的 在Git中更可靠比询问哪些 分支 ,因为在Git中,分支只是便宜的标签,可以从提交中应用和删除,并且可能不再存在于您使用的任何回购/远程交易中。


    My basic git diff doesn't do a whole lot for me. Here I am diffing my master branch against the staging server's master branch:

    (~/hbb.vm) debian $ git diff ..stage/master --name-only
    sites/all/libraries/attachment_email/attachment_email.php
    sites/all/modules/redirect/redirect.module
    sites/all/modules/redirect/redirect.test
    sites/all/themes/HBB/css/elements.css
    sites/all/themes/HBB/templates/node--enterprise_blog.tpl.php
    

    I would like to see info like:

    • has this file been added/modified/deleted?
    • on which branch the file has been added/modified/deleted?

    EDIT: I am not interested in seeing all changes - I want something in between. A rich summary.

    解决方案

    You can use the following command to see a summary of the differences between your current branch and stage/master:

    $ git diff --name-status ..stage/master
    M       practice.txt
    A       shazbot.txt
    D       foobar.txt
    

    where M stands for "Modified", A stands for "Added", and D stands for "Deleted".

    If you want to see in which commits these files were modified, added, or deleted, you can use the log command instead, with the same --name-status argument:

    $ git log --oneline --name-status ..stage/master
    31b9628 Add shazbot.txt
    A       shazbot.txt
    e56da37 Merge branch 'develop'
    790f3bf Revert "Revert "Merge branch 'develop'""
    M       practice.txt
    d9493e0 Merge branch 'master' into develop
    8832960 Revert "Merge branch 'develop'"
    M       practice.txt
    2b82909 Merge branch 'develop'
    2d41fb6 Fix bug 01
    M       practice.txt
    526bf16 Add feature 02
    M       practice.txt
    ba8700c Add feature 01
    M       practice.txt
    bb8ced2 Add practice.txt
    A       practice.txt
    

    Asking about which commits introduce changes is more reliable in Git than asking about which branches, because in Git, branches are just cheap labels that can be applied and removed from commits, and may no longer exist in any of the repos/remotes that you're using.

    这篇关于从我的Git diff命令中寻找更多信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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