Git get list of changes files

I want to get the list of changed files in a repository in a particular folder between two dates.
Please help with the command for this.

git log has --since and --until options, which should help you with that. You can specify paths to look at at the end of the command.

2 Likes

Maybe something along

git log --since=2020-10-01 --until=2020-10-07 --name-only --pretty="format:" | sort -u

to list the files involved in the commits between October 1st and 7th, omitting commit hashes etc. The file names are sorted and duplicates removed (assuming a Unix environment including Git bash).

2 Likes

Thanks Simran, this works.
Also is there a way to get the same done in python 2.7?
I am trying to use subprocess module, but somehow the command prompt gets hung on git log query. Thanks in advance.

Python 2, yikes… the documentation says something about deadlocks:
https://docs.python.org/2.7/library/subprocess.html#using-the-subprocess-module

Python 3 seems to use Popen.communicate() internally for subprocess.run(), which apparently avoids this issue. You might want to pass a timeout in seconds to abort if it takes too long.

proc = subprocess.run(' '.join([
  'git log --name-only --pretty="format:"',
  '--since="2020-10-01" --until="2020-10-07" | sort -u'
]), shell=True, check=True, capture_output=True, encoding="utf-8", timeout=120)
for line in proc.stdout.splitlines():
  print(line)

Not sure what the Python 2 equivalent would be. Also not sure if UTF-8 is actually the default encoding of the shell.