Makefile git add commit push github All in One command

Jun 15 · 2 min read

As a remember, the traditional way of adding a file to a repository using the command line is summarized into 3 steps as follow:

Step 1:

  1. Open the terminal.
  2. Change the current working directory to your local repository.
  3. Stage the file for commit to your local repository by the following command.
$ git add .

Step 2:

Commit the file that you’ve staged in your local repository.

$ git commit -m "Add existing file"

Step 3:

Push the changes in your local repository to GitHub.

$ git push origin branch-name

How to run ALL in one command from within a Makefile?

put all git add, git commit, git push command in a makefile as follow:

Step 1:

You need just to make a “makefile” in your project directory.

Step 2:

put these in that makefile:

git add .
git commit -m "$m"
git push -u origin master

Attention: Each line after git : is starting with a tab. Like this:

Step 3:

In terminal do this:

make git m="your message"

and you will see such message in terminal:

That’s it!


Written by


Web geek, Self-taught full-stack web developer, Physicist PhD, Learning Laravel, Vuejs, UX/UI design