Empower your commit messages with Sugar Git and AI

Discover how this tool changes the way you work with Git commits. Explore the benefits of adopting conventional commits, automation of commit messages with AI, and streamlining of workflows. Boost your productivity and keep your repositories organized with this powerful tool.

Empower your commit messages with Sugar Git and AI

In the realm of version control systems, Git stands out as the de facto standard, offering powerful capabilities for tracking changes in software projects. However, effectively managing Git commits often involves adhering to conventions, maintaining semantic clarity, and ensuring meaningful documentation. This is where Sugar Git comes into play, providing syntactic sugar for Git while respecting modern semantics and conventions. Furthermore, with the integration of Artificial Intelligence (AI), Sugar Git brings an innovative approach to crafting precise and clear commit messages, thus optimizing workflow and increasing productivity.

Understanding Conventional Commits

Before delving into the features of Sugar Git, it's essential to understand the concept of Conventional Commits. Conventional Commits is a specification that proposes a structured commit message format. The goal is to standardize the way developers write commit messages, making them more descriptive, consistent, and machine-readable. The format typically includes a prefix indicating the type of change (e.g., feat for new features, fix for bug fixes), followed by a succinct description and an optional body providing more details.

Key Features of Sugar Git

1. Optimized Workflow

Sugar Git provides a comprehensive array of commands that streamline the Git workflow, encompassing tasks such as preparing changes, committing, resolving conflicts, and pushing to remote repositories. Each command within Sugar Git is meticulously crafted to bolster productivity and ensure consistency across the development cycle.

Here are some key commands offered by the tool:

  1. sgit wipe: Undo all uncommitted changes according to the upstream remote branch.
  2. sgit rollback (shortcut sgit rb): Roll back to the last commit.
  3. sgit edit: Correct mistakes in the last commit message.
  4. sgit amend: Add forgotten files to the last commit.
  5. sgit log or sgit log <search_query> (shortcut sgit l)`: View and find commits.
  6. sgit status (shortcut sgit s): View the staging area.
  7. sgit <type> <description>: Create a commit message according to the Conventional Commits specification, where <type> is the type of change (e.g., feat, fix, chore) and <description> is a brief description of the change.
  8. sgit --help: Browse the full documentation.
Click to see more commands
1$ sgit -h
2sgit - Syntactic sugar for Git, respecting semantics and modern conventions
3
4Usage:
5 sgit COMMAND
6 sgit [COMMAND] --help | -h
7 sgit --version | -v
8
9Branches Commands:
10 ls List all branches, only remote or only local
11 take Create new branch
12 cd Change the current working branch
13 mv Rename some branch
14 rm Delete some branch
15
16State Commands:
17 save Save credentials storage in git repository
18 remote Show the current remote repository
19 wipe Wipe the working branch as per the remote branch
20 rollback Back the commit history, but it preserves the file contents
21 edit Edit some commit message
22 get Fetch and merge changes from remote branch to working branch (pull shortcut)
23 put Send committed changes from working branch to the respective remote branch (push shortcut)
24
25Consult Commands:
26 log Search in the history commit by applying some filters
27 status Show the current state of git working directory and staging area
28 incoming Show the incoming commits from remote branch that is not in the working branch
29 outgoing Show the outgoing commits from working branch that is not in the remote branch
30 committers Show the committers of the current branch
31
32Staging Commands:
33 add Add files or directories to staging area
34 sub Remove files or directories from staging area
35 amend Add all untracked, modified and deleted files to the last commit without edit the message
36 resolve Resolve conflicts in the working branch
37 tag Add an annotated tag with the description same as the message
38
39Commit Commands:
40 commit Use AI to generate a commit message according the description in any language
41 build Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
42 chore Code change that external user won\'t see (eg: change to .gitignore file or .prettierrc file)
43 ci Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
44 docs Documentation only changes
45 feat New feature
46 fix Bug fix
47 localize Translations update
48 perf Code change that improves performance
49 refactor Code change that neither fixes a bug nor adds a feature; refactoring production code, eg. renaming a variable
50 revert Reverts a previous commit
51 style Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
52 test Adding missing tests or correcting existing tests
53
54Completions Commands:
55 completions Generate bash completions
56
57Options:
58 --help, -h
59 Show this help
60
61 --version, -v
62 Show version number
1$ sgit -h
2sgit - Syntactic sugar for Git, respecting semantics and modern conventions
3
4Usage:
5 sgit COMMAND
6 sgit [COMMAND] --help | -h
7 sgit --version | -v
8
9Branches Commands:
10 ls List all branches, only remote or only local
11 take Create new branch
12 cd Change the current working branch
13 mv Rename some branch
14 rm Delete some branch
15
16State Commands:
17 save Save credentials storage in git repository
18 remote Show the current remote repository
19 wipe Wipe the working branch as per the remote branch
20 rollback Back the commit history, but it preserves the file contents
21 edit Edit some commit message
22 get Fetch and merge changes from remote branch to working branch (pull shortcut)
23 put Send committed changes from working branch to the respective remote branch (push shortcut)
24
25Consult Commands:
26 log Search in the history commit by applying some filters
27 status Show the current state of git working directory and staging area
28 incoming Show the incoming commits from remote branch that is not in the working branch
29 outgoing Show the outgoing commits from working branch that is not in the remote branch
30 committers Show the committers of the current branch
31
32Staging Commands:
33 add Add files or directories to staging area
34 sub Remove files or directories from staging area
35 amend Add all untracked, modified and deleted files to the last commit without edit the message
36 resolve Resolve conflicts in the working branch
37 tag Add an annotated tag with the description same as the message
38
39Commit Commands:
40 commit Use AI to generate a commit message according the description in any language
41 build Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
42 chore Code change that external user won\'t see (eg: change to .gitignore file or .prettierrc file)
43 ci Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
44 docs Documentation only changes
45 feat New feature
46 fix Bug fix
47 localize Translations update
48 perf Code change that improves performance
49 refactor Code change that neither fixes a bug nor adds a feature; refactoring production code, eg. renaming a variable
50 revert Reverts a previous commit
51 style Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
52 test Adding missing tests or correcting existing tests
53
54Completions Commands:
55 completions Generate bash completions
56
57Options:
58 --help, -h
59 Show this help
60
61 --version, -v
62 Show version number

These commands are augmented with Sugar Git's alignment with the Conventional Commits specification, simplifying the creation of conventional commit messages. This alignment fosters a clearer and more organized commit history, enabling developers to effectively communicate the nature of changes and automate the generation of release notes and changelogs.

2. Semantic Branch Management

Sugar Git simplifies branch management with its user-friendly commands, adhering to a convention-based approach that allows developers to categorize branches according to their purpose, such as feature branches, bug fix branches, hotfixes, and experiments.

Here are some essential commands provided by Sugar Git for branch management:

  1. sgit ls: List branches.
  2. sgit take <branch_name>: Create a new branch.
  3. sgit cd <branch_name>: Switch to a specified branch.
  4. sgit mv <old_branch_name> <new_branch_name>: Rename a branch.
  5. sgit rm <branch_name>: Delete a branch.
Click to see more commands
1$ sgit take -h
2sgit take - Create new branch
3
4Alias: mkdir
5
6Usage:
7 sgit take [DESCRIPTION] [OPTIONS]
8 sgit take --help | -h
9
10Options:
11 --origin, -o
12 Defines if the branch should also be created in the origin
13
14 --only-origin, -O
15 Defines if the branch should be only created in the origin
16
17 --main
18 The production branch
19
20 --staging, -s
21 Demo branch and decisions about release features
22
23 --test, -t
24 Contains all codes ready for QA testing
25
26 --dev, -d
27 All new features and bug fixes; codes conflicts should be done here
28
29 --feature, -f DESCRIPTION
30 Any code changes for a new module or use case; should be created based on
31 the current development branch
32
33 --bugfix, -b DESCRIPTION
34 If the code changes made from the feature branch were rejected after a
35 release, sprint or demo
36
37 --hotfix, -H DESCRIPTION
38 If there is a need to fix something that should be handled immediately;
39 could be merged directly to the production branch
40
41 --experimental, -e DESCRIPTION
42 Any new feature or idea that is not part of a release or a sprint; a branch
43 for playing around
44
45 --build, -u DESCRIPTION
46 A branch specifically for creating specific build artifacts or for doing
47 code coverage runs
48
49 --release, -r DESCRIPTION
50 A branch for tagging a specific release version
51
52 --merge, -m DESCRIPTION
53 Resolving merge conflicts, usually between the latest development and a
54 feature or hotfix branch; also to merge two branches of one feature
55
56 --help, -h
57 Show this help
58
59Arguments:
60 DESCRIPTION
61 The description is a brief explanation about the branch purpose
62
63Examples:
64 [Command]
65 - sgit take -f "my really awesome feature" -o
66 [Result]
67 - git checkout -b "feature/my-really-awesome-feature"
68 - git push origin "feature/my-really-awesome-feature"
1$ sgit take -h
2sgit take - Create new branch
3
4Alias: mkdir
5
6Usage:
7 sgit take [DESCRIPTION] [OPTIONS]
8 sgit take --help | -h
9
10Options:
11 --origin, -o
12 Defines if the branch should also be created in the origin
13
14 --only-origin, -O
15 Defines if the branch should be only created in the origin
16
17 --main
18 The production branch
19
20 --staging, -s
21 Demo branch and decisions about release features
22
23 --test, -t
24 Contains all codes ready for QA testing
25
26 --dev, -d
27 All new features and bug fixes; codes conflicts should be done here
28
29 --feature, -f DESCRIPTION
30 Any code changes for a new module or use case; should be created based on
31 the current development branch
32
33 --bugfix, -b DESCRIPTION
34 If the code changes made from the feature branch were rejected after a
35 release, sprint or demo
36
37 --hotfix, -H DESCRIPTION
38 If there is a need to fix something that should be handled immediately;
39 could be merged directly to the production branch
40
41 --experimental, -e DESCRIPTION
42 Any new feature or idea that is not part of a release or a sprint; a branch
43 for playing around
44
45 --build, -u DESCRIPTION
46 A branch specifically for creating specific build artifacts or for doing
47 code coverage runs
48
49 --release, -r DESCRIPTION
50 A branch for tagging a specific release version
51
52 --merge, -m DESCRIPTION
53 Resolving merge conflicts, usually between the latest development and a
54 feature or hotfix branch; also to merge two branches of one feature
55
56 --help, -h
57 Show this help
58
59Arguments:
60 DESCRIPTION
61 The description is a brief explanation about the branch purpose
62
63Examples:
64 [Command]
65 - sgit take -f "my really awesome feature" -o
66 [Result]
67 - git checkout -b "feature/my-really-awesome-feature"
68 - git push origin "feature/my-really-awesome-feature"

These commands enable developers to easily perform various operations on branches, including creation, deletion, renaming, and switching. Additionally, developers can learn how to create semantic branches with flags by referring to the documentation with sgit take --help.

3. AI-powered Commit Messages

One of the standout features of Sugar Git is its AI integration for commit message generation. The command sgit commit <description_in_any_language> (shortcut sgit c) helps create a commit message with AI assistance. It will analyze the description of the changes and automatically suggest a precise and clear commit message. This significantly reduces the cognitive load on developers, allowing them to focus more on coding and less on composing commit messages.

Using Sugar Git

Installation

To start using Sugar Git, make sure you have Bash 4.0 or higher, curl, and git installed on your system. You can install Sugar Git using the provided setup script or manually, by downloading the sgit script and making it executable. Additionally, consider configuring your default Git editor and other settings for a smoother experience.

1# Installation via setup script (switch to bash to install)
2bash <(curl -Ls raw.githubusercontent.com/mkuchak/sugar-git/main/setup)
1# Installation via setup script (switch to bash to install)
2bash <(curl -Ls raw.githubusercontent.com/mkuchak/sugar-git/main/setup)

Quick Start

Once Sugar Git is installed, it seamlessly facilitates Git repository management, simplifying every aspect of the Git workflow, from initialization to commit and pushing changes to remote repositories.

Here's how to get started:

1# Create a project and enter the directory
2mkdir my-project
3cd my-project
4
5# Initialize a Git repository and rename the branch to `main`
6git init
7sgit mv master main
8
9# Create files
10npm init -y
11echo "console.log('Hello, world! 🌎')" > index.js
1# Create a project and enter the directory
2mkdir my-project
3cd my-project
4
5# Initialize a Git repository and rename the branch to `main`
6git init
7sgit mv master main
8
9# Create files
10npm init -y
11echo "console.log('Hello, world! 🌎')" > index.js

Now, let's make our first commit with sgit commit:

1sgit c "my first commit, starting the project... added a main file named index.js with a simple print to screen saying hello to the world" -A
1sgit c "my first commit, starting the project... added a main file named index.js with a simple print to screen saying hello to the world" -A

Results to choose from:

  1. feat: create main file index.js with print 'Hello World'

  2. feat: add initial main file index.js with simple print statement

  3. chore: initialize project with main file index.js and basic 'Hello World' print

  4. Generate more commit messages

    • Allows generating additional commit messages or (CTRL+C to exit).

Practical results of the command when choosing option 1:

  • git add --all
  • git commit -m "feat: create main file index.js with print 'Hello World'"

Or, if your commit description is substantial, the commit body is suggested:

1sgit c "I did a major refactoring on buttons, refactored all buttons to aggregate into just one single component that has a variants and size property... this was because it was very confusing, the product team asked to speed up the development of the dashboards, so it was necessary to have everything centralized into just one component with variations because it was better than copying styles from other dashboards and instead centralizing the content, especially since we use quite a lot of similar buttons, there's rarely a new one, and this made everything messy with slightly different buttons that should be identical to each other" -Aep
1sgit c "I did a major refactoring on buttons, refactored all buttons to aggregate into just one single component that has a variants and size property... this was because it was very confusing, the product team asked to speed up the development of the dashboards, so it was necessary to have everything centralized into just one component with variations because it was better than copying styles from other dashboards and instead centralizing the content, especially since we use quite a lot of similar buttons, there's rarely a new one, and this made everything messy with slightly different buttons that should be identical to each other" -Aep

The -Aep flag is a combination of -A (or --add-all) to stage all changes, -e (or --edit) to open the editor to edit the commit message, and -p (or --put) to push the changes to the remote repository after the commit is made. Edit before committing is useful when the commit message is substantial and requires a more detailed explanation or review.

Results to choose from:

  1. refactor: join buttons into single component with variants and sizes

    • Refactored all buttons into a single reusable component that accepts variant and size props. The previous structure was confusing and hindered development speed for dashboards. Centralizing the button styles eliminates inconsistencies and streamlines maintenance as the team frequently uses identical buttons.
  2. refactor: implement button component with variants and sizes

    • Introduced a new feature by implementing a button component that supports variants and sizes. This component streamlines the development of dashboards as per the product team's request, ensuring uniformity and ease of maintenance for different button styles.
  3. refactor: consolidate buttons into single component with variants and sizes

    • Consolidated all buttons into a single component with variant and size properties. The decision to centralize button styles in response to the product team's request for faster dashboard development. This enhancement reduces confusion by standardizing button appearance.
  4. Generate more commit messages

    • Allows generating additional commit messages or (CTRL+C to exit).

Practical results of the command when choosing option 3:

  • git add --all
  • git commit -m "refactor: consolidate buttons into single component with variants and sizes\n\nConsolidated all buttons into a single component with variant and size properties. The decision to centralize button styles in response to the product team's request for faster dashboard development. This enhancement reduces confusion by standardizing button appearance." --edit
  • * Opens the editor to edit the commit message *
  • After saving and closing the editor, the commit will be made with: git push origin main

Conclusion

Sugar Git bridges the gap between Git's power and ease of use, providing developers with a more intuitive and productive experience. By embracing semantic conventions, offering AI-assisted commit message generation, and optimizing Git workflows, Sugar Git empowers developers to focus on writing high-quality code while maintaining clear and informative commit histories.

Whether you're a seasoned Git user or just starting out, Sugar Git is a valuable tool for enhancing your version control workflow.

To get started with Sugar Git, visit the GitHub repository for installation instructions and documentation.


The art of creating

programming
programming
programming
programming
programming
programming