I actively make commits to cxgrd. But running the four git commands add, commit, push and branch again and again was time consuming and boring. So I built a small tool which I call gatm (Git Automation Tool by Manan).
Now I just need to run gatm in my terminal, and it runs add, commit and push by itself.
Install
npm install -g @geekgod382/gatm
I had to name it this way because npm said the name "gatm" is very similar to some other packages.
How it works
When you run gatm it will extract the untracked/modified files and run git add <the changed files>. After this, it deterministically generates a commit message (I just used git status --porcelain for this job) and run git commit -m "message". At last, it runs git push -u origin branch_name to push the commit.
If there are no modified files, it returns "nothing to commit". If push fails because of changes in remote origin, it returns "run git pull first". The extraction of untracked/modified files happens by keeping an eye on .gitignore file, to avoid node_modules or .env files from being committed.
Prerequisites
Git SHOULD BE installed and make sure git init was already ran in the project directory, and a remote origin was added.
Options
gatm supports these options:
-
-m "custom_commit_message": use this option for adding a custom commit message. This will bypass the deterministic message generation. -
-b "new_branch_name": use this option for creating a new branch and commiting to it. When this option is used, gatm will rungit checkout -b new_branch_nameto create and switch to new branch, and then pushes to it. -
-d: a dry run option. This will give you the details about changed files, commit message generated and branching and won't run any command. This option is just for your own satisfaction.
Although I build gatm for my personal use, but I decided to publish it to npm, if someone else struggles with running multiple commands, they can use it too.
GitHub : https://github.com/geekgod382/gatm
I would be very happy to hear your feedback about it.
Top comments (0)