YouTip LogoYouTip

Git Tutorial - Getting Started

Introduction

Git is a distributed version control system that tracks changes in source code. It is essential for modern software development, enabling collaboration and code history management.

Initial Setup

# Configure Git
git config --global user.name "Your Name"
git config --global user.email "you@example.com"

# Initialize a repository
git init

# Clone an existing repository
git clone https://github.com/user/repo.git

Basic Workflow

# Check status
git status

# Stage changes
git add file.txt
git add .          # Stage all changes

# Commit changes
git commit -m "Add new feature"

# View commit history
git log --oneline

Undoing Changes

# Unstage a file
git restore --staged file.txt

# Discard changes in working directory
git restore file.txt

# Amend last commit
git commit --amend -m "Updated message"

Summary

Git basics revolve around init, add, commit, and log. These four commands form the foundation of version control in any project.

← Git Branching and MergingDocker Networking and Volumes β†’