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. This is because GItHub CLI does not replace git.

To commit and push, you can use git on the command-line:

$ git add myfile1.txt myfile2.txt
$ git commit -m "My commit message"
$ git push -u origin HEAD
🌐
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
To create a repository for your project on GitHub, use the gh repo create subcommand. When prompted, select Push an existing local repository to GitHub and enter the desired name for your repository.
Discussions

How to ‘push’ with gh?
There are no gh commands to commit nor push. ... GitHub CLI is a tool to interface with GitHub-specific features. More on github.com
🌐 github.com
7
21
April 14, 2023
git - Uploading a project to GitHub using the command line - Stack Overflow
How do I upload a project to GitHub through the command line? I have installed Git on Windows. I am uploading my project by creating a new repository, but it did not upload by command line. More on stackoverflow.com
🌐 stackoverflow.com
How to avoid the "Where should we push" prompt when running gh pr create?
The documentation reads "When the current branch isn't fully pushed to a git remote, a prompt will ask where to push the branch" - but even I do a git push me before running the gh pr create comman... More on github.com
🌐 github.com
2
6
October 6, 2021
Let the user bypass the pre-check command when pushing
user doesn't have to git push --no-verify first and then run a gh pr create ... Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment ... enhancementa request to improve CLIa request to improve CLIneeds-triageneeds to be reviewedneeds to be reviewed More on github.com
🌐 github.com
1
December 13, 2022
🌐
GitHub
docs.github.com › en › github-cli › github-cli › quickstart
GitHub CLI quickstart - GitHub Docs
GitHub CLI automatically stores your Git credentials for you when you choose HTTPS as your preferred protocol for Git operations and answer "yes" to the prompt asking if you would like to authenticate to Git with your GitHub credentials. This can be useful as it allows you to use Git commands like git push and git pull without needing to set up a separate credential manager or use SSH.
🌐
The New Stack
thenewstack.io › home › git push: how to use the cli to interact with github
Git Push: How to Use the CLI to Interact with GitHub - The New Stack
September 14, 2024 - You’ll be prompted for your GitHub username and password. The password is actually the personal access token you created earlier. Upon successful authentication, you’ll see the changes were pushed to the remote repository.
Find elsewhere
🌐
GitHub
github.com › git-guides › git-push
Git Guides - git push · GitHub
By default, git push only updates the corresponding branch on the remote. So, if you are checked out to the main branch when you execute git push, then only the main branch will be updated.
🌐
GitHub
gist.github.com › 798e01f45e88bbd7b2ad5b5d1dc4ebf5
Git & Github CLI Commands.md · GitHub
Git & Github CLI Commands.md · follow · Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment ·
🌐
Medium
medium.com › it-dead-inside › gh-the-github-cli-8538c1b7a4f2
gh — The GitHub CLI
February 2, 2022 - gh — The GitHub CLI Get to know the super-convenient CLI to save you time and effort doing things on GitHub A guilty confession: I love Git, but I hate the Git command line. Sure, sure, I know. I …
🌐
Visual Studio Code
code.visualstudio.com › docs › sourcecontrol › intro-to-git
Quickstart: use source control in VS Code
November 3, 2021 - Open the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)) and run Publish to GitHub.
🌐
Graphite
graphite.com › guides › how-to-push-to-github
How to push to GitHub
Learn the various ways to push your code from your local repository to GitHub using the command line and VSCode, including pushing changes, branches, and files.
🌐
GitHub
docs.github.com › en › get-started › git-basics › set-up-git
Set up Git - GitHub Docs
You can authenticate to GitHub using GitHub CLI, for either HTTPS or SSH. For more information, see gh auth login. If you clone with HTTPS, you can cache your GitHub credentials in Git using a credential helper. For more information, see About remote repositories and Caching your GitHub credentials in Git. If you clone with SSH, you must generate SSH keys on each computer you use to push or pull from GitHub.
🌐
GitHub
github.com › cli › cli › issues › 6728
Let the user bypass the pre-check command when pushing · Issue #6728 · cli/cli
December 13, 2022 - user doesn't have to git push --no-verify first and then run a gh pr create ... Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment ... enhancementa request to improve CLIa request to improve CLIneeds-triageneeds to be reviewedneeds to be reviewed
🌐
The Odin Project
theodinproject.com › lessons › foundations-git-basics
Git Basics | The Odin Project
Finally, let’s upload your work to the GitHub repository you created at the start of this tutorial. Type git push. To be more specific, type git push origin main. Since you are not dealing with another branch (other than main) or a different ...
🌐
GitHub
cli.github.com › manual › gh_auth_login
GitHub CLI | Take GitHub to the command line
Authenticate with a GitHub host · The default hostname is github.com. This can be overridden using the --hostname flag
🌐
Earth Data Science
earthdatascience.org › home
First steps with git: clone, add, commit, push | Earth Data Science - Earth Lab
September 12, 2017 - After you’ve pushed your commits, visit your repository on GitHub and notice that your changes are reflected there, and also that you have access to the full commit history for your repository! ... Learn how to calculate seasonal summary values for MACA 2 climate data using xarray and region mask in open source Python.
🌐
GitHub
cli.github.com › manual
Manual | GitHub CLI
GitHub CLI, or gh, is a command-line interface to GitHub for use in your terminal or your scripts.
🌐
YouTube
youtube.com › watch
Git CLI #2: How to Push Files to GitHub Using Add, Commit, and Push - YouTube
After creating a new GitHub repository, we need to know how to push files online. In this video, I showcase how we can utilize the basics of Git to push file...
Published: July 30, 2024