Skip to content
\n

Currently, after running such code, a commit is created with no changes to the files. I can't find any function that checks for any changes before commit after adding files. I don't mean changes to all code and to all files in the main .git folder, but changes to one file and one folder with many files.

\n

I am also looking for a solution other than using untracked_files in a loop looking to see if my needed files are there.

","upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"

A commit has a link to a tree, which identifies the state of all files contained with it.
\nThus, if the tree hash does not change between commits, they refer to the same state.
\nI believe one can get a handle on a tree with commit.tree.

\n

Even though I am closing the issue, please feel free to keep posting here for any follow ups.

","upvoteCount":1,"url":"https://github.com/gitpython-developers/GitPython/discussions/1162#discussioncomment-408817"}}}

Don't commit if this would be an empty commit #1162

Answered by Byron
mhajder asked this question in Q&A
Discussion options

You must be logged in to vote

A commit has a link to a tree, which identifies the state of all files contained with it.
Thus, if the tree hash does not change between commits, they refer to the same state.
I believe one can get a handle on a tree with commit.tree.

Even though I am closing the issue, please feel free to keep posting here for any follow ups.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by mhajder
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1056 on February 26, 2021 11:18.