I'm currently using git for managing several projects, however, one question has been bugging me recently: what is the good tone for committing modifications to the master branch and to secondary branches? Should it be 'commit when it compiles', 'commit when it works', or something else? Thanks.
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- What is the tortoisehg gui equivalent of doing “hg
- How to use Mercurial from Visual Studio 2010?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is it possible to do a “destroy history” in TFS?
- Is there a version control system abstraction for
Some basic things:
To take it one step back, I try to work on issues/bugs/features that can be completed in a short period of time. If it's going to take more than a day to come to a good stopping point the task is too big.
That said, I think the best practice is to commit your changes when the code compiles and has been adequately tested (ideally with unit or integration tests that get committed with the code change).
If compiles + functions properly + is well tested == 'commit when it works' then that seems like the appropriate rule.
Commit when it works. In my case this means to: automate the smoke test, run it and commit.
Note: its just the smoke tests that I automate/run before the commit. Regression tests are left to the continuous integration.
I go with 'commit early, commit often', myself. If you have an automated checkout and build going on, this obviously won't work.
If you are using a ticket management system, I would say commit when a task is fixed.
Commit only one type of change at a time.
What "type" means is different for each project, but some popular examples include "cosmetic changes" vs "functional changes" and "refactoring" vs "adding new". This makes it easier to follow the changes when looking at the log, and also easier to revert to a revision.