Hi there, I am going to show you how to automate your most used git commands in just three lines of code.
Our program will be able to run add, commit and push commands for us in just on call. Let me show you.
Writing the script
We are using shell script or bash to run our commands for us.
- We will have to create a file name script.sh You can change the name to anything but maintain the .sh extension.
2.Then we write the code
#!/bin/bash
# This is the add command that will run add all your modified files to the working tree
git add .
# The git command takes an argument when running the script to use as the commit message
git commit -m "$1"
# Finally we push our code.
git push
And that's it, we are done.
Then we can run the script by running bash script.sh "commit message here"
in the terminal.
Top comments (0)