GitHub Repositories
What
A GitHub repository is an external, cloud-hosted copy of your Git project. You can link your local project folder to an empty GitHub repository, enabling safe command-line synchronization.
How
The workflow to link a local repository to GitHub involves:
-
Authenticate: Log in to your GitHub account on your command line using the GitHub CLI (
gh):gh auth login -
Add Remote: Create a blank repository on GitHub’s website and register its URL in your local project:
# HTTPS syntax git remote add origin https://github.com/your-username/my-project.git # SSH syntax git remote add origin git@github.com:your-username/my-project.git -
Verify: Query the remote connection parameters to ensure that Git successfully registers the link:
# Query remote connection details git ls-remote
Why
Authenticating and linking your local workspace to an empty, clean remote repo is the initial bootstrap step for every new software project. By establishing the origin pointer to a secure GitHub address, you unlock the ability to safely backup and share your codebase with just a single command.
Summary
Link local projects to GitHub by logging in with gh auth login and registering your project’s GitHub URL locally using git remote add origin <url>.