Git Basics

Assignment 2 - Version Control Fundamentals

Introduction to Git

Git is a distributed version control system that helps manage project history and collaboration. This assignment demonstrates the fundamental Git commands and workflows used in real-world projects.

Learning Objectives

  • Learn Git basics and essential commands
  • Use branches effectively for feature development
  • Understand merging and conflict resolution
  • Host code on GitHub and manage repositories
  • Review commit history and track changes

Git Workflow Screenshots

Git Init

1. Initialize Repository

Creating a new Git repository with git init

Git Add and Commit

2. Stage and Commit Files

Using git add and git commit to save changes

Git Branch

3. Create and Switch Branches

Creating a new branch with git branch and git checkout

Git Merge

4. Merge Branches

Merging feature branch into main with git merge

Git Push

5. Push to GitHub

Pushing code to remote repository with git push

Git Log

6. Review Commit History

Viewing commit history with git log

Essential Git Commands

git init

Initialize a new Git repository

git add .

Stage all changes for commit

git commit -m "message"

Commit staged changes with a message

git branch <name>

Create a new branch

git checkout <branch>

Switch to a different branch

git merge <branch>

Merge branch into current branch

git push

Push commits to remote repository

git log

View commit history