GitHub GitGitHubPull RequestsVersion Control

Article & Tutorial

GitHub for Beginners: Git, Repositories, Branches and Pull Requests

Learn GitHub fundamentals including Git, repositories, commits, branches, pull requests, authentication, collaboration, common commands and team workflows.

GitHub repository interface used for branches, commits and collaborative pull requests
GitHub repository interface used for branches, commits and collaborative pull requests
Contents

Last reviewed: September 2026

GitHub is a cloud platform for hosting Git repositories and collaborating on software. Git records file history locally; GitHub stores remote repositories and adds pull requests, code review, issues, automation, permissions and security features.

Git and GitHub are different

GitGitHub
Version-control softwareHosted collaboration platform built around Git
Runs locallyHosts remote repositories
Tracks commits and branchesAdds reviews, issues, Actions and access controls
Can work without a networkConnects contributors and automation

Core concepts

ConceptPurpose
RepositoryProject files, configuration and Git history
CommitRecorded snapshot with author, timestamp and message
BranchIndependent line of work based on a commit
RemoteNamed connection to another repository, commonly origin
Pull requestProposal to review and merge branch changes
IssueTracked bug, task, request or discussion
ForkIndependent server-side copy used for contribution or experimentation

Configure Git

Install Git using the supported package for your operating system. Set the name and email recorded in new commits, select main as the default initial branch, and review the resulting configuration. A repository can override global settings when a different identity is required.

Create and publish a repository

  1. Create an empty repository on GitHub if the local project already contains files.
  2. Open a terminal in the local project directory and initialize Git.
  3. Review files and add an appropriate ignore file.
  4. Stage only the intended files and create a focused initial commit.
  5. Add the GitHub repository as the origin remote.
  6. Push the main branch and confirm the files appear correctly.

Before the first commit, check for local configuration, generated output, large binaries and information that does not belong in source control.

Clone an existing repository

Copy the HTTPS or SSH repository address from GitHub and use Git clone. The clone contains the project files and history and normally configures a remote named origin. Follow the repository's contribution and setup documentation before changing files.

Work on a feature branch

  1. Update the local main branch using the team's approved policy.
  2. Create a short-lived branch with a descriptive name.
  3. Make one focused change and inspect the working tree and diff.
  4. Stage only related files and create a meaningful commit.
  5. Push the feature branch and open a pull request.

A good pull request explains the purpose, scope, test evidence, risk and deployment notes. Keep unrelated changes out of the same request.

Review and merge pull requests

  • Use draft status while work is incomplete.
  • Request review from people who understand the affected area.
  • Respond to comments with code changes or a clear explanation.
  • Require automated checks that reflect the repository's quality gates.
  • Resolve conversations only after the concern is addressed.
  • Use the team's approved merge method and remove obsolete branches.

Connect securely

For command-line access, follow GitHub's current documentation for HTTPS with GitHub CLI or a supported credential manager, or configure SSH. Choose the method required by your organization and limit access to the necessary repositories and actions.

  • Enable two-factor authentication and protect recovery methods.
  • Do not place access details in repository files or build logs.
  • Use the narrowest permissions that support the task.
  • Set expiration and rotation policies where supported.
  • Remove access promptly when it is no longer required.

Useful Git commands

CommandPurpose
git statusShow staged, modified and untracked files
git diffShow unstaged changes
git diff --stagedShow changes prepared for commit
git log --oneline --graph --allDisplay compact branch history
git fetch --pruneDownload remote references and remove stale tracking references
git pull --ff-onlyUpdate only when no merge commit is required
git switch BRANCHMove to another branch

Resolve common problems

  • Access failed: inspect the remote address and confirm that the selected connection method has repository access.
  • Push rejected: fetch current history and integrate it using the team's approved policy.
  • Merge conflict: read both versions, keep the intended result, test it and obtain review when uncertain.
  • Unexpected files staged: review the staging area and remove unrelated files before committing.

Recommended team controls

  • Protect important branches and require pull requests.
  • Require relevant reviews and status checks.
  • Use CODEOWNERS where ownership rules are useful.
  • Keep commits focused and messages meaningful.
  • Run tests, linting and security checks before merge.
  • Limit administrative permissions and review access regularly.
  • Use verified commits or workflows where policy calls for them.
  • Back up critical repository and release assets according to business requirements.

Practice workflow

  1. Create a small repository with a README and ignore file.
  2. Create a feature branch and make one focused change.
  3. Inspect the diff and commit it with a meaningful message.
  4. Push the branch and open a pull request.
  5. Review the change, run checks and merge it.
  6. Update the local main branch and remove the obsolete feature branch.

Official references

GitHub Get Started documentation

Connecting to GitHub with SSH

About pull requests

Managing protected branches

Did this help?

Yes No

Join the discussion

0 Comments

Ask questions, add context, or share what worked.

Sign in to join the discussion

No comments yet. Start the discussion.

More from Melochip Editorial

Related articles

Stay in the loop. Get new Melochip articles

Receive Melochip article updates when new articles are available. Explicit opt-in only.

No pre-checked boxes. Unsubscribe support is part of the subscriber foundation.