Sitelet https://web.archive.org/web/20220425124810/https://github.com/cli/cli/discussions/3093
Skip to content

how to commit and push using cli ? #3093

Answered by mislav
rockey5520 asked this question in Q&A
how to commit and push using cli ? #3093
Mar 6, 2021 · 2 answers · 2 replies

how to commit and push using cli ? cant seem to find the command in the manula

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

Replies

2 suggested answers
·
2 replies

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
2 replies
@rockey5520

out of curiosity, wondering there is an option to clone a repo but not commit :)

gh repo clone x/x

@mislav

mislav Mar 15, 2021
Maintainer

That's a good question. We decided to make some git operations easier, such as cloning. A regular clone would look like this:

git clone https://github.com/owner/repo.git

With GitHub CLI, it can be shorter:

gh repo clone owner/repo

In this case, GitHub CLI wraps a git command and we add some value for the user. But most other git commands we do not wrap, and you should still use them directly, such as git commit. For now, we decided not to wrap git commit because we do not think gh can right now add any value to the commit operation.

We might wrap the git push operation in the future: #2189

Answer selected by mislav

Thank you so much for explaining the reasons behind this conscious decision.

btw, I thoroughly enjoyed your experience on building gh in Go Time podcast episode last year.

0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants