# Committing code efficiently

This is how I commit my code.

I use Git as the Version Control System. 

Yet, the following concepts is applicable for any version control system (vcs).

### Design Principles:
- I want to use the same git workflow as much as possible, on different projects
- My pull requests should be easy to review and debug
- Have an easy way to setup my workflow and configure
- Ensure linting and security
- Should be able to make changes to my workflow

### Use :
-  ` git diff --check`, identifies any possible white space errors and lists them for you.  Add this as a git hook.

-  Commit messages should be around 50 to 60 characters long, at max, like how one limits 120 characters per line 
when writing code

- Make separate commits for separate changes

- Use imperative tone, for your commit messages
    - Example : `Make IndexController check for token` over `Made changes to ensure IndexController checks for token`
    - Reason: Concise and the intent of the change is better understood right away

- Using git config i.e. `.gitconfig` file , to set the up required info. Such as :
    - GPG signature, Author info
    - Reason: To make the commit more readable and secure. This depends on the use case

- Ensure no sensitive info is checked-in as part of the commit. One should have an automated way, of checking this type of change.
    - Reason:  To minimise the security exposure and decrease the cost of setup going forward
    - Tools to enforce the checks: 
        - https://rtyley.github.io/bfg-repo-cleaner/
        - https://github.com/auth0/repo-supervisor
        - More at info at : https://geekflare.com/github-credentials-scanner/

- 🏭 🏭 Automate as much as of the git workflow, as possible. Ensure the onboarding of this workflow is simple or at least not too cumbersome
     - It's also scalable, when working in a team and easier to enforce rules
      - I use [Fig.io](https://fig.io) and aliases to use commands faster

 You can make incremental changes over time to your workflow and setup.

### Sources I have used for reference: 

- [Git Documentation for Submitting patches](https://git.kernel.org/pub/scm/git/git.git/tree/Documentation/SubmittingPatches?id=HEAD#n133)
- [Dotfiles](https://dotfiles.github.io)

For any feedback, you can tweet me at :  [@vaikuntj](https://twitter.com/vaikuntj).

Cheers :). Have a great day 🎉🎉
