Basically, git commit "records changes to the repository" while git push "updates remote refs along with associated objects". So the first one is used in connection with your local repository, while the latter one is used to interact with a remote repository.
Here is a nice picture from Oliver Steele, that explains the Git model and the commands:

Read more about git push and git pull on Pushing and pulling (the article I referred to first).
how to commit and push using cli ?
Whats the purpose of a git commit VS git push?
git add, commit and push commands in one? - Stack Overflow
Do you add commit push after you push?
Videos
Basically, git commit "records changes to the repository" while git push "updates remote refs along with associated objects". So the first one is used in connection with your local repository, while the latter one is used to interact with a remote repository.
Here is a nice picture from Oliver Steele, that explains the Git model and the commands:

Read more about git push and git pull on Pushing and pulling (the article I referred to first).
commit: adding changes to the local repository
push: to transfer the last commit(s) to a remote server
Just to be clear, I know what git add, commit, and push all do. When I write code and I solved some bug, what I do is
git add . git commit -m "this thing finally works' git push origin main
I never do a commit that I don't push right after. And that's because I don't get why I should commit what I don't intend to push. And if I don't intent to push, why commit? Just to be clear, I know HOW these commands work. I don't understand their WHY.
Building off of @Gavin's answer:
Making lazygit a function instead of an alias allows you to pass it an argument. I have added the following to my .bashrc (or .bash_profile if Mac):
function lazygit() {
git add .
git commit -a -m "$1"
git push
}
This allows you to provide a commit message, such as
lazygit "My commit msg"
You could of course beef this up even more by accepting even more arguments, such as which remote place to push to, or which branch.
I ended up adding an alias to my .gitconfig file:
[alias]
cmp = "!f() { git add -A && git commit -m \"$@\" && git push; }; f"
Usage: git cmp "Long commit message goes here"
Adds all files, then uses the comment for the commit message and pushes it up to origin.
I think it's a better solution because you have control over what the commit message is.
The alias can be also defined from command line, this adds it to your .gitconfig:
git config --global alias.cmp '!f() { git add -A && git commit -m "$@" && git push; }; f'
I've been trying to research and figure out git but I am just a bit confused about push. Push puts your work on github right? Well what if I'm still making changes on my work? Do i then add/commit/push again? Like the first time i did it? Do i just commit push commit push?
After cloning a GitHub repository to my local computer via HTTPS, I made code modifications locally, performed a 'git add' and 'git commit.' However, when attempting to execute 'git push origin main,' I encountered a prompt for my username and password. I initially tried entering the credentials saved in Safari, but I received an error. How can I resolve this issue? I also attempted to paste the password from both '/.ssh/id_rsa' and '/.ssh/id_rsa.pub' without success.