Detail change after Git pull

前端 未结 4 2021
小鲜肉
小鲜肉 2020-12-07 07:16

After a Git pull, its output gives a summary on the change amount.

How can I see each or some of the files detailed changes?

Okay, here is my question to Jef

4条回答
  •  借酒劲吻你
    2020-12-07 07:47

    1. How do I know if I was pulling to master? All I did is "git pull".

    The command itself works like this:

    git pull [options] [ […]]
    

    and per default refers to the current branch. You can check your branches by using

    git branch -a
    

    This will list your local and remote branches like for e.g so (Added a --- as divider between local and remote to make it more clear)

    *master
    foo
    bar
    baz
    ---
    origin/HEAD -> origin/master
    origin/deploy
    origin/foo
    origin/master
    origin/bar
    remote2/foo
    remote2/baz
    

    When you then take a look at one remote repo, you will see what you are referring to:

    git remote show origin
    

    will list like the following:

    * remote origin
      Fetch URL: ssh://git@git.example.com:12345/username/somerepo.git
      Push  URL: ssh://git@git.example.com:12345/username/somerepo.git
      HEAD branch: master
      Remote branches:
        foo    tracked
        master tracked
      Local refs configured for 'git push':
        foo    pushes to foo    (up to date)
        master pushes to master (fast-forwardable)
    

    So it's quite easy to be sure where to pull from and push to.

    3. how to see the detail change in a specific file?

    4. how to see the change in summary output by last git pull again?

    The easiest and most elegant way (imo) is:

    git diff --stat master@{1}..master --dirstat=cumulative,files
    

    This will give you two blocks of information about the changes in between your last pull an the current state of work. Example output (I added a --- as divider between --stat and --dirstat output to make it more clear):

     mu-plugins/media_att_count.php                     |  0
     mu-plugins/phpinfo.php                             |  0
     mu-plugins/template_debug.php                      |  0
     themes/dev/archive.php                             |  0
     themes/dev/category.php                            | 42 ++++++++++++++++++
     .../page_templates/foo_template.php                |  0
     themes/dev/style.css                               |  0
     themes/dev/tag.php                                 | 44 +++++++++++++++++++
     themes/dev/taxonomy-post_format.php                | 41 +++++++++++++++++
     themes/dev/template_parts/bar_template.php         |  0
     themes/someproject/template_wrappers/loop_foo.php  | 51 ++++++++++++++++++++++
    ---
     11 files changed, 178 insertions(+)
      71.3% themes/dev/
      28.6% themes/someproject/template_wrappers/
     100.0% themes/
      27.2% mu-plugins/
       9.0% themes/dev/page_templates/
       9.0% themes/dev/template_parts/
      63.6% themes/dev/
       9.0% themes/someproject/template_wrappers/
      72.7% themes/
    

提交回复
热议问题