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).

Answer from tanascius on Stack Overflow
🌐
GitHub
docs.github.com › en › migrations › importing-source-code › using-the-command-line-to-import-source-code › adding-locally-hosted-code-to-github
Adding locally hosted code to GitHub - GitHub Docs
When prompted, select Push an existing local repository to GitHub and enter the desired name for your repository. If you want your project to belong to an organization instead of your user account, specify the organization name and project name with ORGANIZATION-NAME/PROJECT-NAME. Follow the interactive prompts. To add the remote and push the repository, confirm yes when asked to add the remote and push the commits to the current branch.
Discussions

how to commit and push using cli ?
Hi, you cannot commit nor push using GitHub CLI. If you look at gh help, you will see commands related to GitHub Issues, Pull Requests, Releases, and so on. But there are no commands to make commits. More on github.com
🌐 github.com
2
1
March 6, 2021
Whats the purpose of a git commit VS git push?
Some programmers like to have a clean commit history, so after they make all the commits like "A small fix", "Correction to the fix", "It works this time" etc, they squash commits and rewrite them so they make sense. Also, one might not want to have their commits on the server before it's finished so it can be rebased and corrected without force pushing. More on reddit.com
🌐 r/learnprogramming
28
48
February 6, 2023
git add, commit and push commands in one? - Stack Overflow
# Stage all unstaged files git ... --git-dir=$PWD/.git push # Push to remote end · Restart terminal, navigate to project, make changes, and now you can call 'quickgit "example message"'. Changes will now be added, committed, and push :). Also can be found as a Gist here: https://gist.github.com/Abush... More on stackoverflow.com
🌐 stackoverflow.com
Do you add commit push after you push?
With push you put your latest commit and all commits before that on the server (GitHub, BitBucket, GitLab, or anything else). In that way you can share the changes you made with others, and make sure they're backed up. You don't have to push after each commit. As I mention before, when you push, you send your latest and all earlier commits that the server doesn't have in the current branch. My workflow generally is that I add and commit multiple times, and only push data to the server once in a while, e.g. before lunch and when I stop working. More on reddit.com
🌐 r/git
16
3
July 29, 2021
🌐
GitHub
github.com › git-guides › git-push
Git Guides - git push · GitHub
Then, push the new branch up to the remote: git push -u origin [branchname] Checkout to the branch that you intended to commit to: git checkout [branchname] Merge the commits from the branch that you did accidentally commit to: git merge [main] ...
🌐
Earth Data Science
earthdatascience.org › home
First steps with git: clone, add, commit, push | Earth Data Science - Earth Lab
September 12, 2017 - Using either method, we can see that the file structure of our cloned repo mirrors the file structure of our forked GitHub repo. Next, open up your favorite text editor and make a few edits to the README.md file. Save your changes. Once you are happy with your changes and have saved them, go back to your terminal window and type git status and hit return to execute the command. ... On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: README.md no changes added to commit (use "git add" and/or "git commit -a")
Find elsewhere
🌐
Zapier
zapier.com › productivity › app tutorials
How to push to GitHub | Zapier
April 24, 2025 - You can enter anything for the commit message, but adding -m "[commit message]" specifies what this code change is doing, so it's helpful to be clear and concise. Enter git push origin [branch name] to save your code changes to GitHub.
🌐
DataCamp
datacamp.com › tutorial › git-push-pull
Git Push and Pull Tutorial | DataCamp
July 23, 2019 - However, if you are new to Git, have a look at our GitHub and Git Tutorial for Beginners and set up your environment using our Git setup guide. ... git push uploads your local commits to a remote repository like GitHub, while git pull downloads changes from a remote repository and merges them ...
🌐
Git Tower
git-tower.com › learn › git faq › how to push to github
How to Push to GitHub | Learn Version Control with Git
1 month ago - In the dialog, you can enter a ... your local repository · from now on, you can simply use the "Push" button in the toolbar to upload new changes to the remote on GitHub...
🌐
Graphite
graphite.com › guides › git-add-commit-push
Git add, commit, and push - Graphite
Even if you create multiple commits, those commits live only on your machine, inside your local Git repository. To share these changes with others, you use git push. git push sends your local commits to a remote repository (often hosted on platforms ...
🌐
Reddit
reddit.com › r/learnprogramming › whats the purpose of a git commit vs git push?
r/learnprogramming on Reddit: Whats the purpose of a git commit VS git push?
February 6, 2023 -

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.

🌐
GitHub
github.com › marketplace › actions › github-commit-push
GitHub Commit & Push · Actions · GitHub Marketplace
Needs to be used with force input to force push the amended commit. ... Determines if force push is used. ... Determines if --tags is used. ... Determines if git pull --rebase is used before the push. This is useful if multiple actions try to push at the same time. ... Directory to change to before pushing. ... Repository name. Default or empty repository name represents current github repository. If you want to push to other repository, you should make a personal access token and use it as the github_token input.
🌐
GitHub
github.com › git-guides › git-commit
Git Guides - git commit · GitHub
If you'd like to include more context ... or staging directory, and any other important information. git push: Uploads all local branch commits to the remote....
🌐
GeeksforGeeks
geeksforgeeks.org › git › what-is-git-push
Git Push - GeeksforGeeks
1 month ago - ... If you see an error such as “origin does not appear to be a git repository”, it means no remote repository is configured. ... To link your local repository to a GitHub repository, use the git remote add command in the project directory.
🌐
Intro to GIS
mgimond.github.io › Intro-to-git-GitHub › stage_and_push.html
Staging/committing and pushing to GitHub | Intro-to-git-GitHub
Proceed with the following steps when you are ready to stage, commit, then push (upload) your local project folder back to your github account. Note that you do not need to wait until you feel as though you have a final version of your assignment or project before pushing it to your github account.
🌐
Sos-cer
sos-cer.github.io › projects › git-guide › git-push.html
Push Your Local Repository to Your Remote Repository
Once again, the Git Bash output ... allowed to git push your own code. If you Commit and Push as the last step in committing files to your local repository, then your code is automatically pushed to your remote repository at NCSU GitHub....
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › How-to-push-an-existing-project-to-GitHub
How to git push an existing project to GitHub
Use Git to clone the GitHub repo locally. Copy your project files into the folder created by the clone. Perform a git add . and a git commit. Push your changes up to GitHub.
🌐
Reddit
reddit.com › r/github › how to push git commit to github?
r/github on Reddit: How to push git commit to GitHub?
October 2, 2023 -

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.