Question

git mv foldera folderb, results in all the files in foldera being moved to folderb. Using DiffFormatter I can see DiffEntry objects for each file.

However, that doesn't tell the whole story. Specificially, from the DiffEntry objects I can't determine if foldera was renamed to folderb, or did folderb already exist prior to the commit and the 2 files were individually moved in the commit, leaving foldera having 2 fewer files in it. Is there a different class to inspect the commit to get this information?

Was it helpful?

Solution

Git tracks changes in files, not folders. If you just created folderb, git wouldn't recognize it(even if you git add folderb). If you moved all the files from foldera to folderb, git wouldn't know that foldera still exists.

In other words, unless there is some plugin that tracks folders in git repositories, you can't discriminate between those two cases - because that information doesn't exist in the repository. Git doesn't know there are foldera and folderb - all it knows is that there are some files with foldera/ and folderb/ in their paths.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top