GitHub is an online platform for hosting and managing Git repositories. It provides version control, collaboration tools, and integration with various development workflows. Developers use GitHub to store code, track changes, and collaborate on projects through features like pull requests, issues, and discussions. It also supports automation, continuous integration, and project management tools. While primarily used for software development, GitHub is also popular for documentation, research, and other collaborative projects.
To push to a remote repository hosted on GitHub, you need to have access to it by either being invited or being the owner. Then, Git needs to authenticate your credentials to allow pushing your commits. The easiest way to manage authentication is by using the GitHub CLI (gh
).
Windows
Install with winget
, open a terminal and run:
winget install --id GitHub.cli
macOS
Install with Homebrew
, open a terminal and run:
brew install gh
Linux
Install using your package manager:
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
sudo dnf config-manager addrepo --from-repofile=https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install gh --repo gh-cli
sudo pacman -S github-cli
Once installed, you need to authenticate with GitHub:
Open a terminal and run:
gh auth login
GitHub.com
when prompted.Choose between authenticating via HTTPS
or SSH
. If unsure, HTTPS
is the easier option.
Note:
HTTPS authentication will require a web browser. This is not useful for headless installations.
If using HTTPS, you can authenticate via a web browser or a personal access token (PAT). The recommended way is to use the web authentication:
Login with a web browser
and follow the instructions to authorize GitHub CLI.repo
scope.After authentication, verify that you’re logged in by running:
gh auth status
This will cache your credentials in Git, next time you run git push origin
, it will already have access to your account.
gh
Here is a list of commands you will find useful.
gh repo clone <owner>/<repository>
gh repo create <repository-name> --public
gh pr list
gh notifications
GitHub Desktop is a graphical user interface (GUI) application that simplifies working with Git repositories. It allows users to clone repositories, commit changes, create branches, and push updates without using the command line.
Follow the instructions in their downloads page