Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
125 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...