0

I'm trying to list as last changes that were sent to a branch develop, for this I execute the git log --pretty='format:%H' --after='${formatYesterday}' --before='${formatToday} and I get the hash of the last changes in the last 24 hours, then with a list of several hashes I trying the git diff --name-only ${GIT_LIST_COMMITS[cont]} to list the changed/deleted/deleted files in the commit But, in tests this already worked and a few days later it does not work(does not list files) anymore (in Jenkins and Git Bash).

In short: I need to list the files changed by the hash and this is not working.

Is Git failing or am I using GIT DIFF incorrectly?

user2831852
  • 535
  • 2
  • 7
  • 22
  • Don't you want `--name-status` rather than `--name-only`? (since you want the file statuses (M,D,A,R,...). Also, can you extend on your *does not work anymore*? – Romain Valeri Jan 25 '19 at 11:05
  • Git diff does not list the files, returns nothing. Git stays in TFS, I searched for the hash in TFS and it returned the changes, so should list the files in bash, right? – user2831852 Jan 25 '19 at 11:29
  • Possible duplicate of [How to list all the files in a commit?](https://stackoverflow.com/questions/424071/how-to-list-all-the-files-in-a-commit) – phd Jan 25 '19 at 12:39
  • https://stackoverflow.com/search?q=%5Bgit%5D+list+files+commit – phd Jan 25 '19 at 12:39
  • I found the mistake. **git log** takes the last changes in the last 24 hours and the last commit in the branch feature occurred two days before, so probably the hash that git log found was from the merge that does not have the changes. Is there a way to identify the feature by the hash found in the branch develop? – user2831852 Jan 25 '19 at 13:56
  • 1
    What you want is unclear, and your current state is unclear. Do you want the most recent changes, or all changes from the past day? If "most recent", is the "1 day" period even relevant, or just someone assumed looking at the most recent day would include the most recent changes? You say that in a case where the most recent changes was 2 days ago, you assume it picked up "the merge"... what merge? – Mark Adelsberger Jan 25 '19 at 15:00
  • The approval of the pull request took more than 24 hours and because of this the commits history of the feature was not picked up in my git log, the hash that was identified seems to be the hash of the merge that updated Develop with the Feature and it does not have commits information (that was the problem). Now I'm looking for a way to get the list of changes to the features that were merged with the develop and avoid the problem. Is there a way to do this? – user2831852 Jan 25 '19 at 17:40
  • I found this command here in Stackoverflow: `git diff --name-only ^ ` and it looks like it has resolved since it now lists all changed files in the feature. I just do not understand why `^ `, anyone know? – user2831852 Jan 25 '19 at 20:17

0 Answers0