Why is output from 'git diff' different than 'git show'? -
i expected git show <commit> , git diff <commit>^ <commit> show changes took place in given commit, see list of changes differs. (see example below.) what's correct understanding of function, then?
yes, i've read man pages
git show
for commits shows log message , textual diff. presents merge commit in special format produced git diff-tree --cc. git diff
git diff [--options] <commit> <commit> [--] [<path>...] view changes between 2 arbitrary <commit>. e.g.
$ my_commit=7c95d118c9837f801f4e314732c593e25feba3b1 git show , output:
$ git show --name-only $my_commit commit 7c95d118c9837f801f4e314732c593e25feba3b1 merge: 5f308b4 9ef9bd7 author: me <quinesquines@gmail.com> date: thu apr 23 14:14:58 2015 -0700 merge branch 'develop' of github.com:pic-development/dataraptor develop conflicts: app/controllers/application_controller.rb app/controllers/usage/staff_assignment_controller.rb app/views/crm/connections/_show.html.erb app/views/crm/task_builders/_task_builders.html.haml spec/controllers/contacts_controller_spec.rb spec/controllers/crm/connections_controller_spec.rb app/controllers/application_controller.rb app/controllers/usage/staff_assignment_controller.rb app/views/crm/connections/_show.html.erb git diff , output:
$ git diff --name-only $my_commit^ $my_commit app/assets/javascripts/application/quoting/ng-new-quote.js app/assets/stylesheets/application-layout.css.scss app/assets/stylesheets/application.css app/controllers/application_controller.rb app/controllers/crm/connections_controller.rb app/controllers/usage/staff_assignment_controller.rb app/models/crm/connection.rb app/models/usage/permissions.rb app/views/crm/connections/_show.html.erb app/views/crm/task_builders/_task_builder.html.erb app/views/layouts/application.html.erb app/views/marketing/campaigns/_index.html.haml app/views/marketing/campaigns/_task_builders.html.haml app/views/shared/tab/_agency_management.html.erb app/views/shared/tab/_contracts.html.erb app/views/shared/tab/_help.html.erb app/views/shared/tab/_marketing.html.erb app/views/shared/tab/_my_account.html.erb app/views/shared/tab/_reporting.html.erb app/views/shared/tab/_sales_tools.html.erb app/views/shared/tab/_system_management.html.erb app/views/shared/tab/_underwriting_suitability.html.erb app/views/usage/agent_field_sets/_new_submission_option.html.erb app/views/usage/users/_personal.html.erb vendor/assets/stylesheets/bootstrap-combined.min.css vendor/assets/stylesheets/bootstrap.css vendor/assets/stylesheets/pixel-admin.css vendor/assets/stylesheets/themes.css
you displaying diff of merge commit.
consider example following commits (f being newest one), , you're doing git show f , git diff f^ f (which git diff c f).
a--b--c--f \ / d----e git showshows only files changed in merge commit itself. may include files had merge conflicts manually fixed. not show files modified in 1 of merged branches (so b,c or d,e) , merged cleanly. quote man page (emphasis mine):for commits [git show] shows log message , textual diff. presents merge commit in special format produced git diff-tree --cc.
[git diff-tree --cc] further compresses patch output omitting uninteresting hunks contents in parents have 2 variants , merge result picks 1 of them without modification.
git diff <commit>^ <commit>shows diff of merge commit's first parent , merge commit. since merge commit contains changes both first , second parent, you're shown diff of the entire branch (so in example, commit d , e) merged in commit.
Comments
Post a Comment