Git and GitHub for Beginners

Git is a distributed version-control system. GitHub is a hosted platform built around Git repositories that adds collaboration features such as pull requests, reviews, issues, and project automation.

The basic workflow

git clone <repository-url>
cd my-project
git status
git add .
git commit -m "Save my changes"
git push

This workflow starts by getting a repository, checking its state, staging changes, recording a commit, and sending the commit to a remote repository.

What is a commit?

A commit is a recorded snapshot of changes in your local repository. Good commit messages describe the change clearly so you can understand the history later.

What is a branch?

A branch lets you work on a separate line of development without immediately changing another branch.

git switch -c my-feature

Keeping feature work on its own branch makes it easier to review, test, and merge.

Pull and push

git pull retrieves remote changes and integrates them into your local work, while git push publishes local commits to a remote repository. Before pushing, checking git status and reviewing your commits can prevent accidental changes from being shared.

Branches and pull requests

A common GitHub workflow is to create a branch, make several focused commits, push the branch, and open a pull request. The pull request gives collaborators a place to review the changes before they are merged into the target branch.

Handling merge conflicts

A merge conflict occurs when Git cannot automatically combine competing changes. Open the affected files, choose the intended result, remove the conflict markers, then stage and commit the resolved files.

git status
git add .
git commit -m "Resolve merge conflict"

Common beginner mistakes

A practical learning path

Start by making small commits locally, then practice branches and merge conflicts. Once the workflow is comfortable, learn pull requests, code review, tags, and release management on GitHub.

Next step

Practice on a small project, then explore the Developer Tools pillar and your chosen language pillar as you build larger projects.

đŸ’Ŧ Comments

Sign in with Google to publish immediately, or comment anonymously and wait for approval.

Comments will appear here when available.