diff --git a/docs/tutorial/basics/committing.md b/docs/tutorial/basics/committing.md index e69de29..0e0c53f 100644 --- a/docs/tutorial/basics/committing.md +++ b/docs/tutorial/basics/committing.md @@ -0,0 +1,47 @@ +# Commiting Changes + +# Committing Changes in Git + +## Overview + +In Git, **committing changes** is the process of saving a snapshot of your project history. Before committing, files go through different stages. Understanding these stages is key to using Git effectively. + +--- + +## File Stages in Git + +Git tracks the state of every file in your project. These states define how Git sees each file before committing: + +### 🔹 Untracked Files + +These are new files in your working directory that Git doesn't know about yet. + +- **Not being tracked** by Git +- Will not be part of any commit until added + +--- + +- These files are ready to be committed + +--- + +### 🔹 Committed Changes + +Once files are staged, you can commit them to the repository history, creating a snapshot of the changes. + +--- + +## Summary of Commands + +| Action | Command | +| --- | --- | +| Check file status | `git status` | +| Add new/modified file to staging | `git add ` | +| Unstage a file | `git restore --staged ` | +| Commit staged changes | `git commit -m "message"` | + +--- + +## Conclusion + +Committing in Git isn’t just a single step—it’s the final stage in a flow that moves files from **untracked → unstaged → staged → committed**. Mastering this flow is essential for effective version control. \ No newline at end of file diff --git a/docs/tutorial/basics/history.md b/docs/tutorial/basics/history.md index e69de29..df0f840 100644 --- a/docs/tutorial/basics/history.md +++ b/docs/tutorial/basics/history.md @@ -0,0 +1,66 @@ +# Viewing History + +# Viewing History in Git + +## Overview + +Viewing the history of your project in Git allows you to track changes over time. Git keeps a detailed record of every commit made to the repository. You can explore this history using various commands, each showing different aspects of the commit history. + +--- + +## Key Commands for Viewing History + +Git provides several commands to view your repository's history. Here's a summary of the most common ones: + +| Command | Description | +| --- | --- | +| `git log` | Displays the commit history. | +| `git log --oneline` | Shows a simplified log, one line per commit. | +| `git show ` | Shows detailed information about a specific commit. | +| `git log ` | Shows the commit history for a specific file. | + +--- + +## Viewing Commit History + +### 🔹 Basic Log + +The most commonly used command to view the history of commits is `git log`. It shows detailed information about each commit, including the commit hash, author, date, and commit message. + +```bash +git log +``` + +### 🔹 Simplified Log + +For a more concise view, `git log --oneline` shows each commit in a single line, displaying the commit hash and the commit message. + +```bash +git log --oneline +``` + +### 🔹 Showing Specific Commits + +To view detailed information about a specific commit, use `git show `, replacing `` with the commit hash. This will display changes made in the commit, along with the commit metadata. + +```bash +bash +CopyEdit +git show +``` + +## Viewing History for Specific Files + +### 🔹 History of a Specific File + +If you want to view the commit history for a specific file, use `git log `. This will show all the commits that modified that particular file. + +```bash +git log +``` + +## Conclusion + +Viewing the history in Git provides insight into how a project evolves over time. By using various log options and commands, you can easily track changes, identify contributors, and understand the development process. + +Mastering these commands will allow you to navigate your project's history with ease and efficiency. \ No newline at end of file diff --git a/docs/tutorial/basics/repositories.md b/docs/tutorial/basics/repositories.md index e69de29..5df183d 100644 --- a/docs/tutorial/basics/repositories.md +++ b/docs/tutorial/basics/repositories.md @@ -0,0 +1,96 @@ +# Repositories + +```markdown + +# 🗃️ Git Repositories: A Quick Guide + +This guide explains essential repository operations in Git, including creating, connecting, cloning, and forking, along with a summary table of commands. + +--- + +## 1️⃣ How to Create a Repository with `git init` + +To start a new Git repository in your local project directory: + +```bash +git init +``` + +This command creates a `.git/` folder that tracks all version history and enables Git operations. + +✅ **Example:** + +```bash +mkdir my-project +cd my-project +git init +``` + +--- + +## 2️⃣ How to Connect the Repository to a Global (Remote) Repository + +Once your local repo is ready, connect it to a remote repository (e.g., on GitHub): + +```bash +git remote add origin +``` + +✅ **Example:** + +```bash +git remote add origin https://github.com/username/my-repo.git +``` + +To push your code for the first time: + +```bash +git push -u origin main +``` + +--- + +## 3️⃣ How to Clone a Repository + +To copy a remote repository to your local machine: + +```bash +git clone +``` + +✅ **Example:** + +```bash +git clone https://github.com/username/project.git +``` + +--- + +## 4️⃣ How to Fork a Repository + +Forking a repository is done through platforms like GitHub: + +1. Go to the repository page on GitHub. +2. Click the **Fork** button (top right corner). +3. This creates a copy of the repo under your GitHub account. + +To work with the fork: + +```bash +git clone https://github.com/your-username/forked-repo.git +``` + +--- + +## 6️⃣ Summary Table of Commands + +| Command | Description | +|------------------------------------|-----------------------------------------------------| +| `git init` | Initializes a new Git repository locally | +| `git remote add origin ` | Connects local repo to a remote repository | +| `git push -u origin main` | Pushes commits to the remote for the first time | +| `git clone ` | Clones a remote repository to your local machine | +| *(Forking is done via GitHub)* | Fork a repo through the GitHub UI | + +--- +```