Connect to GitHub
GitHub is the most popular platform for hosting Git repositories. In this chapter, you’ll create a GitHub account and connect your local repository to a remote on GitHub.
Step 1: Create a GitHub Account
Go to github.com and sign up. Choose a username, provide your email, and set a password. Verify your email address.
Step 2: Create a New Repository on GitHub
After logging in, click the + icon in the top‑right corner and select New repository. Give it a name (e.g.,
my-first-project). You can add a description and choose public or private. Do not initialize with README, .gitignore, or license (since you already have a local repo). Then click Create repository.Step 3: Link Your Local Repository to GitHub
GitHub will show you commands to push an existing repository. On your terminal, inside your local Git project, run:
git remote add origin https://github.com/your-username/my-first-project.gitReplace the URL with the one shown on GitHub.Step 4: Verify the Remote
Run
git remote -v. You should see two lines: fetch and push, both pointing to your GitHub repository.Authentication (Optional)
When you push for the first time, Git may ask for your GitHub username and password. As of 2021, GitHub no longer accepts passwords for Git operations. You need to use either:
- Personal Access Token (PAT): Create one in GitHub Settings → Developer settings → Personal access tokens, and use it as a password.
- SSH keys: More secure, but requires setup (we’ll cover in advanced topics).
Two Minute Drill
- Create a GitHub account and a new empty repository.
- Add the remote with
git remote add origin. - Verify with
git remote -v. - Use a personal access token or SSH for authentication.
Need more clarification?
Drop us an email at career@quipoinfotech.com
