IMHO This will be possible, only if
- You are the only programmer contributing
- You are using only one local repository to push changes to remote
And this takes away the flexibility and power git gives you.
If so,
you can use 'alias'
So something like this can do the job.
$ gitFunction() {
> git add .
> git commit -m "$1"
> git push origin }
$ alias git-all="gitFunction"
$ git-all 'commit message' //Will do everything for you.
Or
Add this to your .git/config file.
[alias]
sync = "!sync() { git add . && git commit -m \"$1\" && git push $2; }; sync"
Later you can use
$git sync 'commit message' remote_repo
But you shouldn't be doing this!!
Why?
Though off the topic, I would love to quote Principle of sufficient reason
Nothing is without a reason or cause
Git, when designed by Linus had these steps separate because of sufficient reason. If you are abusing it then you won't get the full potential out of it. So its good to have best practices followed.
From what you intend to achieve, you view git as, just a tool to upload your source-code changes into a remote server, which is by the way wrong and takes away all the goodness git gives you.
Why git add
shouldn't be automated?
git add helps you to add untracked files/ add modified files into staging area. Which will later go into your commit. Doing git add .
will add everything into your staging area. Most times you will have something, that you don't want to commit or to be there in a specific commit.
Why git commit -m "Message"
shouldn't be automated?
A commit message explains the changes that happened after the last commit. A commit message helps other programmers collaborating with you to understand the changes you have done. So you shouldn't be writing senselessness in a commit message
Why git push
shouldn't be automated?
Even with your present logic, this step should fail if you are not the only programmer contributing to the project. So there will be changes in remote, which you should be pulling. And in best case an automatic merge will happen and you can directly do a git push as next step. But in case of a conflict, you need to resolve the conflicts, then commit the changes, merge and then push (which by the way, is not easy to automate if possible).
Also you won't be pushing into same remote and you won't be pushing the same branch all the time. All these things are variable and needs the developers decision.
So, try understanding Git and then give a second thought on these.
Read Pro Git it is free and best book on git.