问题
I'm using poetry for my Python package manager but I believe this would apply to any programming practices.
I've been doing this without knowing exactly what I'm doing, or how I should be doing.
When you use a package manager and install a new package, there's usually a .lock
file change to keep your build deterministic.
Usually, I would commit these changes like:
$ git add poetry.lock pyproject.toml
$ git commit -m "Install packages: beautifulsoup4"
i.e, I make a commit every time I install/remove a package. I do it because I FEEL like this is what I should do, but I have 0 clue if this is actually a correct way to handle this.
Am I doing great? or is there any other specific convention & rules I should abide by to make it follow the best practices as close as possible?
回答1:
During development, it isn't necessary to commit lockfiles and share a single one between team members. The pyproject.toml
file is the reference for correct build instructions, and the lockfile is the reference for a single working platform specific deployment.
It is not unusual for projects to keep updating a single lockfile since it cuts down on build time, but I wouldn't consider it a best practice. Arguably, adding poetry.lock
to the .gitignore
is a better practice than what you do, and only commit pyproject.toml
changes when you add dependencies.
来源:https://stackoverflow.com/questions/61037557/should-i-commit-lock-file-changes-separately-what-should-i-write-for-the-commi