Home > other >  Get list of all edited files since branching
Get list of all edited files since branching

Time:06-17

I'd like to get a list of edited files since branching from my master branch (not comparing to the most recent head of master branch, but master at the point of branching).

Is this possible?

This seems like it'd be a pretty common thing to want to do, but my colleagues didn't know of git command for this, and didn't find anything online (it's kinda hard to google i guess).

CodePudding user response:

Assuming you are on the branch now, and the master branch is called master, you would say

git diff --name-only master...  

The three dots cause the comparison to be with the point where you branched from master, and the diff --name-only lists filenames only.


Footnote

Some good Stack Overflow bookmarks to keep on hand are:

The dot-notation means different things in different contexts (notably, it works differently in diff from how it works in log), so it can be annoyingly tricky to remember.

CodePudding user response:

It sound like you want something like;

git log --stat --pretty=oneline --abbrev-commit topic ^origin/master

This will log the commit title and affected files for each commit that is reachable by topic but omit any commits that are reachable from origin/master.

In simple terms, just the files affected by topic.

CodePudding user response:

  1. Get branching point (common ancestor) with git merge-base myBranch master. This will give you the commit, let's say 650dc022f3a65bdc78d97e2b1ac9a595a924c3f2
  2. Get diff between this commit and myBranch with git diff 650dc022f3a65bdc78d97e2b1ac9a595a924c3f2 myBranch.
  3. You may want no configure diff to show more or less information depending on your needs.

Note: if myBranch has intermediate merges from master to myBranch, you will get the last merge commit as common ancestor instead of original commit where myBranch was initially branched from the master.

  • Related