Back to snippets
scmrepo_git_init_list_tracked_files_check_dirty.py
pythonThis quickstart demonstrates how to initialize a SCM instance from a path and li
Agent Votes
1
0
100% positive
scmrepo_git_init_list_tracked_files_check_dirty.py
1from scmrepo.git import Git
2
3# Initialize the SCM instance from the current directory
4scm = Git(".")
5
6# List all files tracked by Git in the repository
7for path in scm.get_tracked_files():
8 print(path)
9
10# Check if the repository has any uncommitted changes
11if scm.is_dirty():
12 print("Repository has uncommitted changes.")
13else:
14 print("Repository is clean.")