Most modern software project management systems provide functionality which allows to comment issues/tasks with special syntax in commit messages. For example, Redmine does it quite well and additionally allows to log time to issues. Github also provides great integration between issues and commits.