I have a repo which contains two sub dirs - stage
and prod
. There can be two processes running on a machine one for stage and one for prod, these processes would commit changes to respective folders. Now for each commit I want to find files which were modified, added or deleted. And I found a lot of solutions like this. But the problem is what if one process commits to prod folder and then the second process commits to stage folder, and I use above method then I would get the wrong diff I would essentially get files changed in both commits. One simple solution to this problem seems to be to make two different repos for stage and prod. Does anyone have any other solutions so that I can just get the difference of a file from the last commit, i.e, if the change is in stage dir I get the difference of only that file from the last commit and not find the difference between two trees.
Asked
Active
Viewed 83 times
0

arielBodyLotion
- 47
- 1
- 8
-
I think Git will not allow you to commit two commits with the same parent to the same HEAD. You would need to rebase whichever commit comes last. Regarding your actual question, if you diff a commit with its parent, you will alway only see the changes within this commit. – Rüdiger Herrmann Sep 09 '21 at 21:25
-
@RüdigerHerrmann Firstly what I mean is one commit comes first and the second commit is its child, I am not saying the two processes are trying to commit to same HEAD. Secondly just to confirm you are saying say first commit had a change in prod folder in file A and the second commit had a change in stage folder in file B. Then the diffFormatter.scan will only return file B? – arielBodyLotion Sep 10 '21 at 04:16
-
A diff is always between two (or more) commits. As long as you compare a commit with its direct parent, you will see only changes of that exact commit. – Rüdiger Herrmann Sep 10 '21 at 11:07