user14098813
user14098813

Reputation:

What is the difference between git and Github CLI or gh?

What is the difference between git and GitHub CLI? Which one should I use, git or GitHub CLI or gh depending on the situation? For example, cloning a repository, both commands support it. What gives? I am specifically asking for the GitHub CLI not GitHub itself.

Upvotes: 36

Views: 31700

Answers (3)

ARIF MAHMUD RANA
ARIF MAHMUD RANA

Reputation: 5186

git is used for git in general. You can use Bitbucket or GitLab, or any provider with it. You just add a repo and you can push.

But GitHub CLI (gh) is for GitHub. With gh you can manage many features of Github from CLI e.g issues.

I personally prefer git as I am more comfortable with it and in many offices I don't use Github. https://git-scm.com/docs/git-remote.html#_examples

Upvotes: 28

user14098813
user14098813

Reputation:

As said before that gh is for GitHub, literally the description says:

Work seamlessly with GitHub from the command line.

Regarding about the similar commands of cloning a repositoy (I feel like I remember what I was asking):

  • git clone has more limited syntax than gh repo clone (gh repo clone OWNER/REPO)
  • using gh repo clone to clone a fork and automatically add the GitHub upstream repository

Upvotes: 6

VonC
VonC

Reputation: 1328842

Another difference, since Sept. 2021, is its extensibility.

Creating GitHub CLI extensions

GitHub CLI extensions are custom GitHub CLI commands that anyone can create and use. For more information about how to use GitHub CLI extensions, see "Using GitHub CLI extensions"

You need a repository for each extension that you create. The repository name must start with gh-. The rest of the repository name is the name of the extension. At the root of the repository, there must be an executable file with the same name as the repository. This file will be executed when the extension is invoked.

While you can create aliases with git commands, you now can create complexe commands with gh extensions.

Upvotes: 6

Related Questions