简体   繁体   中英

How to get commits and changes in committed files from current branch?

I use query like:

git cherry -v feature/Mappers feature/samples/Automapper

And this enables me to get numbers and commits I need. Like this:

+ 54ee7b846897b0221920140fae12518877788684 Add initial web project for automapper.
+ 707aff03cb8baef0d67ab6304b2f64cfbd54fc1c Delete useless usings.
+ cd2d8acf843c4ec57f4c05a01c14bc53e13c76da Add package for Automapper.
+ 89d063052723977bf5b73a630941bd920c7d3b7b Configure middleware for automapper usage.
+ a5086f947df333e702c7794dc287ef84e0b7343e Add base model for dal layer.
+ 11ac745e252a7ca8b47ca19322df02c9569a85ea Add user model for ui layer.
+ dcb042a4a0b7c4b6eaed679f239023e176c45730 Rename dto model.
+ 95ce33de2d2370e9849ae684d56fb1a92ecf6fcb Add controller, service, interface.
+ 22e71bf78c4e519fe7c6b0b8d32d3650eebf0ee4 Add models for layers.
+ a7f105b9d5f0d24a8c3560e1413280692f0e24e5 Add contexts for database.
+ 03e2c7cf22cb93a286b2f07fb38feee906e664ce Add mapping profile.
+ e1c480606522f70471bf52562cd950bc45f1fb39 Add automapper, swagger, dbcontext to middleware.
+ 750e987057503a534da6c5547e18b753720cd9ab Add connection string to appsettings.
+ d9b66db789df46460a7e3a987cff652c0105661c Add packages.

But without output of changes in files.

How could I get not only commits but changes also from committed files from the current branch?

The git-show command can help you with that, it prints out the commit of a specific hash and the changes done in it.

For example, this is the output of git show ( HEAD by default):

commit 6ac439bd518be4c0845f9508f06d69f0cb90c82b (HEAD -> master, origin/master, origin/HEAD)
Author: Your-name <Your@email.com>
Date:   Thu Oct 14 21:18:37 2021 -0500

    Your commit message

diff --git a/describe.c b/describe.c
index fabadb8..cc95eb0 100644
--- a/describe.c
+++ b/describe.c
@@@ -98,20 -98,12 +98,20 @@@
    return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
  }

- static void describe(char *arg)
 -static void describe(struct commit *cmit, int last_one)
++static void describe(char *arg, int last_one)
  {
 +  unsigned char sha1[20];
 +  struct commit *cmit;
    struct commit_list *list;
    static int initialized = 0;
    struct commit_name *n;

 +  if (get_sha1(arg, sha1) < 0)
 +      usage(describe_usage);
 +  cmit = lookup_commit_reference(sha1);
 +  if (!cmit)
 +      usage(describe_usage);
 +
    if (!initialized) {
        initialized = 1;
        for_each_ref(get_name);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM