How to get the list of changed files since the creation of a branch in git

Suppose I create a branch dev and then made 5 commits and total files changed were 5.

Is there any command that I can run to see only the list of files changed since the branch was created?

  • Why GIT reports “fatal: This operation must be run in a work tree” when exporting from bare repo?
  • Re splitting a merged development branch from Master in Git
  • Ignoring certain files in directory even when adding directory with -f
  • How to print the output of GitK
  • Git doesn't see new files
  • How does git-svn behave with svn repositories that have changed layout?
  • JIRA and private Git repository integration
  • GIT GUI for solo project: Windows PC for development, but git + active, working project repo on a LAN headless linux server?
  • --git-dir not using the given folder, instead creating a different one with repository name
  • Icons on Git Files in local machine
  • Git commit fails with Vim and GVim
  • Only allow 'git push heroku master' from the master branch
  • One Solution collect form web for “How to get the list of changed files since the creation of a branch in git”

    Branches don’t retain “creation” information, so you cannot get git to do this completely automatically and generally. However, if you know there are 5 “interesting” commits:

             A <- B <- C <- D <- E   <- dev
            /
    ... <- * <- o <- ...  <-- master
    

    and you want to compare commit E, the tip of branch dev, to commit *, the commit before commit A:

    $ git diff dev~5 dev
    

    will show you a complete diff of the two. The ~5 notation means “count back five parents”: start at E, step back one to D, step back one to C, etc.; if you do this five times you land on the commit marked *.

    The diff shows you the difference between these two commits. By default, it shows you everything, but if you want to see the names of files changed (or added or deleted, etc.), you can add --name-only.


    Typically a better way to do this is not to care when branch dev was created, but only where dev and some other branch (such as master) join up. In this case, for instance, you might want to locate commit * by asking: “Where do master and dev first join up in history, starting from the tips of dev and master and working backwards?”

    To find this, you can ask git for the “merge base” of the two branches:

    $ git merge-base dev master
    

    This will produce the raw commit-ID of the merge-base (commit * in the drawing). You can then feed this to git diff (with --name-only, --name-status, --stat, or whatever you like):

    $ git diff --name-status $(git merge-base dev master) dev
    

    This is common enough to want, that git diff re-uses the special master...dev syntax (see gitrevisions for details):

    $ git diff --name-status master...dev
    

    The three-dot syntax here tells git diff to find the merge-base, and produce the diff between that and the commit identified on the right: the tip of branch dev.

    Git Baby is a git and github fan, let's start git clone.