diff --git a/docs/github/_category_.json b/docs/github/_category_.json new file mode 100644 index 0000000..1a7c296 --- /dev/null +++ b/docs/github/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "GitHub", + "position": 4, + "link": { + "type": "generated-index", + "description": "Learn React.js for building user interfaces, and learn how to use React.js with other technologies like Redux, Webpack, and ES6." + } + } \ No newline at end of file diff --git a/docs/github/clone-a-repository.md b/docs/github/clone-a-repository.md new file mode 100644 index 0000000..37c5f5a --- /dev/null +++ b/docs/github/clone-a-repository.md @@ -0,0 +1,88 @@ +--- +id: clone-a-repository +title: Clone a Repository +sidebar_label: Clone a Repository +sidebar_position: 4 +description: Learn how to clone a repository from GitHub to your local machine using Git. Clone a project, work on it locally, and push your changes back to GitHub. +tags: [github, git, version control, collaboration, beginners] +keywords: [github, git, version control, collaboration, beginners, open source, repository, clone, project] +--- + +**To work on a project from GitHub, you need to clone the repository to your local machine. This allows you to make changes to the project, work on new features, and contribute to the codebase.** + + + +
+ + +To clone a repository from GitHub, follow these steps: + +1. Go to [GitHub](https://github.com/) and log in to your account. After logging in, you will see your GitHub dashboard. + + + ![GitHub Login](img-12.png) + + +2. Navigate to the repository you want to clone. You can find repositories on your dashboard, in your profile, or by searching for a specific repository. + + + ![Repository List](img-13.png) + + +3. Click on the repository you want to clone to open its main page. On the main page, you will see the repository details, code, issues, and other information. For example, let's clone the "hello-world" repository. + + + ![Repository Main Page](img-14.png) + + +4. Click on the "Code" button to open the code download options. You can clone the repository using HTTPS, SSH, or GitHub CLI. For this tutorial, we will use HTTPS. + + + ![Code Download Options](img-15.png) + + +5. Copy the HTTPS URL of the repository. You will use this URL to clone the repository to your local machine. + + + ![HTTPS URL](img-16.png) + + + + +
+ +6. Open your terminal or command prompt on your local machine. Navigate to the directory where you want to clone the repository. Use the `cd` command to change directories. + + ```bash title="Terminal" + cd path/to/directory + ``` + +7. Clone the repository using the `git clone` command followed by the HTTPS URL you copied earlier. This command will download the repository to your local machine. + + :::tip Note: + Replace `chh-user` with the **username** of the repository owner and `hello-world` with the name of the repository you want to clone. + ::: + + ```bash title="Terminal" + git clone https://github.com/chh-user/hello-world.git + ``` + + ![alt text](img-17.png) + + +8. After cloning the repository, you can navigate to the project directory using the `cd` command. + + ```bash title="Terminal" + cd hello-world + ``` + +9. You have successfully cloned the repository to your local machine. You can now work on the project, make changes to the code, and push your changes back to GitHub. + + ```pwsh + # Make changes to the code + # Add new features + # Fix bugs + # Push changes back to GitHub + ``` + +Congratulations! You have successfully cloned a repository from GitHub to your local machine. You can now start working on the project, collaborate with others, and contribute to the codebase. Happy coding! \ No newline at end of file diff --git a/docs/github/commit-changes.md b/docs/github/commit-changes.md new file mode 100644 index 0000000..df15ed0 --- /dev/null +++ b/docs/github/commit-changes.md @@ -0,0 +1,65 @@ +--- +id: commit-changes +title: Commit Changes +sidebar_label: Commit Changes +sidebar_position: 7 +description: Learn how to commit changes to a Git repository using Git. Commit your changes, add a commit message, and keep track of your project history with Git commits. +tags: [github, git, version control, collaboration, beginners] +keywords: [github, git, version control, collaboration, beginners, open source, commit, changes, history, project] +--- + +**To save your changes to a Git repository, you need to commit them. Committing changes creates a snapshot of your project at a specific point in time, allowing you to track the history of your project and collaborate with others.** + + + +
+ +To commit changes to a Git repository, follow these steps: + +1. Open your terminal or command prompt on your local machine. Navigate to the directory of your Git repository using the `cd` command. + + ```bash title="Terminal" + cd path/to/repository + ``` + +2. Check the status of your repository to see which files have changed. Use the `git status` command to view the changes that are not yet staged for commit. + + ```bash title="Terminal" + git status + ``` + + The `git status` command will show you the files that have been modified, added, or deleted since the last commit. + +3. Stage the changes you want to commit using the `git add` command. This command adds the changes to the staging area, preparing them for the next commit. + + ```bash title="Terminal" + git add filename + ``` + + :::tip Note: + Replace `filename` with the name of the file you want to stage. You can also use `git add .` to stage all changes in the repository. + ::: + +4. Commit the changes using the `git commit` command. This command creates a new commit with the changes you staged in the previous step. + + ```bash title="Terminal" + git commit -m "Add new feature to the project" + ``` + + :::tip Note: + Replace `"Add new feature to the project"` with a meaningful commit message that describes the changes you made in this commit. + ::: + + + +
+ +5. Verify the commit by checking the commit history of your repository. Use the `git log` command to view the commit history, including the commit message, author, date, and commit hash. + + ```bash title="Terminal" + git log + ``` + + The `git log` command will display a list of commits in reverse chronological order, showing the most recent commits first. + +6. Congratulations! You have successfully committed changes to your Git repository. Your project history is now updated with the new commit, and you can continue working on your project with confidence. \ No newline at end of file diff --git a/docs/github/create-a-branch.md b/docs/github/create-a-branch.md new file mode 100644 index 0000000..6b55d3d --- /dev/null +++ b/docs/github/create-a-branch.md @@ -0,0 +1,78 @@ +--- +id: create-a-branch +title: Create a Branch +sidebar_label: Create a Branch +sidebar_position: 5 +description: Learn how to create a new branch in a Git repository. Create a branch to work on new features, bug fixes, or experiments without affecting the main codebase. +tags: [github, git, version control, collaboration, beginners] +keywords: [github, git, version control, collaboration, beginners, open source, branch, create, new, feature, bug fix] +--- + +**To work on new features, bug fixes, or experiments in a Git repository, you need to create a new branch. Branches allow you to work on different parts of the codebase without affecting the main branch.** + + + +
+ +:::caution Prerequisites +- Make sure you have installed Git on your local machine and configured it with your GitHub account before creating a new branch. If you haven't done this yet, follow the **[official Git installation guide](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)**. +- Always create a new branch for each new feature, bug fix, or experiment to keep your codebase clean and organized. +- Make sure you have downloaded the VS Code editor from the official website before following this tutorial. If you haven't done this yet, you can download it from **[https://code.visualstudio.com/](https://code.visualstudio.com/)**. +- VS Code is a popular code editor that provides built-in Git support, making it easy to work with Git repositories directly from the editor. +::: + +To create a new branch in a Git repository, follow these steps: + +1. Open VS Code and open the project you want to create a branch in. + +2. Open the terminal in vs code. + +3. Run the following command to create a new branch. Replace `branch-name` with the name of your new branch. + + ```bash title="Terminal" + git checkout -b branch-name + ``` + + :::tip Note: + The `-b` flag is used to create a new branch. If you want to switch to an existing branch, you can omit the `-b` flag. + ::: + +4. Your new branch is now created. You can start working on new features, bug fixes, or experiments in this branch without affecting the main codebase. + +5. To switch between branches, use the `git checkout` command followed by the branch name. + + ```bash title="Terminal" + git checkout main + ``` + + This command will switch to the `main` branch. Replace `main` with the name of the branch you want to switch to. + +6. To list all branches in the repository, use the `git branch` command. + + ```bash title="Terminal" + git branch + ``` + + This command will list all branches in the repository and highlight the current branch with an asterisk (`*`). + + + +
+ +7. To delete a branch, use the `git branch -d` command followed by the branch name. + + ```bash title="Terminal" + git branch -d branch-name + ``` + + This command will delete the specified branch. Be careful when deleting branches, as this action cannot be undone. + +8. To push a new branch to GitHub, use the `git push` command followed by the branch name. + + ```bash title="Terminal" + git push origin branch-name + ``` + + This command will push the new branch to GitHub, allowing you to collaborate with others and share your work. + +Congratulations! You have successfully created a new branch in your Git repository. You can now work on new features, bug fixes, or experiments in this branch without affecting the main codebase. \ No newline at end of file diff --git a/docs/github/create-a-github-account.md b/docs/github/create-a-github-account.md new file mode 100644 index 0000000..51b68ca --- /dev/null +++ b/docs/github/create-a-github-account.md @@ -0,0 +1,44 @@ +--- +id: create-a-github-account +title: Create a GitHub account +sidebar_label: Create a GitHub account +sidebar_position: 2 +description: Learn how to create a GitHub account in a few simple steps. Get started with GitHub and start collaborating with others, contributing to open-source projects, and building your portfolio. +tags: [github, git, version control, collaboration, beginners] +keywords: [github, git, version control, collaboration, beginners, open source, repository, account, sign up] +--- + +**To get started with GitHub, you need to create a GitHub account. If you already have a GitHub account, you can skip this step.** + + + +
+ +1. Go to [GitHub](https://github.com/) and click on the "Sign up" button. + + + ![GitHub Sign Up](img-1.png) + + +2. Enter your email address, choose a username, and create a password. + + + ![Create Account](img-2.png) + + +3. Click on the "Create account" button. +4. Verify your email address. + + You will receive an email from GitHub with a link to verify your email address. Click on the link to verify your email address. + + + ![Verify Email](img-3.png) + + +5. Congratulations! You now have a GitHub account. + + + ![GitHub account](img-4.png) + + +Now that you have created a GitHub account, you can start using GitHub to collaborate with others, contribute to open-source projects, and build your portfolio. \ No newline at end of file diff --git a/docs/github/create-a-new-repository.md b/docs/github/create-a-new-repository.md new file mode 100644 index 0000000..406d981 --- /dev/null +++ b/docs/github/create-a-new-repository.md @@ -0,0 +1,73 @@ +--- +id: create-a-new-repository +title: Create a New Repository +sidebar_label: Create a New Repository +sidebar_position: 3 +description: Learn how to create a new repository on GitHub in a few simple steps. Start a new project, share your code with others, and collaborate with your team using GitHub repositories. +tags: [github, git, version control, collaboration, beginners] +keywords: [github, git, version control, collaboration, beginners, open source, repository, create, new, project] +--- + +**To get started with GitHub, you need to create a new repository. If you already have a repository, you can skip this step.** + + + +
+ +## Create a New Repository + +To create a new repository on GitHub, follow these steps: + +1. Go to [GitHub](http://github.com/) and log in to your account. + + + ![GitHub Login](img-1.png) + + +2. Click on the "+" icon in the top right corner of the page and select "New repository" from the dropdown menu. + + + ![New Repository](img-5.png) + + +3. Enter a name for your repository in the "Repository name" field. (For example, "hello-world") + + + ![Repository Name](img-6.png) + + +4. Optionally, you can add a description for your repository in the "Description" field. + + + ![Repository Description](img-7.png) + + + + +
+ +5. Choose the visibility of your repository. You can make it public or private. + + + ![Repository Visibility](img-8.png) + + +6. Select the "Initialize this repository with a README" checkbox if you want to create a README file for your repository. + + + ![Initialize Repository](img-9.png) + + +7. Click on the "Create repository" button to create your new repository. + + + ![Create Repository](img-10.png) + + +8. Your new repository is now created. You can start adding files, folders, and code to your repository. + + + ![Repository Created](img-11.png) + + +Congratulations! You have successfully created a new repository on GitHub. You can now start working on your project, share your code with others, and collaborate with your team using GitHub repositories. \ No newline at end of file diff --git a/docs/github/create-a-pull-request.md b/docs/github/create-a-pull-request.md new file mode 100644 index 0000000..b41d544 --- /dev/null +++ b/docs/github/create-a-pull-request.md @@ -0,0 +1,167 @@ +--- +id: create-a-pull-request +title: Create a Pull Request +sidebar_label: Create a Pull Request +sidebar_position: 9 +description: "Learn how to create a pull request (PR) on GitHub to propose changes, collaborate with others, and contribute to open-source projects." +tags: [github, git, pull request, collaboration, open source, beginners, contribution] +keywords: [create pull request, github pr, git pr, merge changes, collaboration, contribution, beginners guide] +--- + +Once you’ve made changes to your code and pushed them to GitHub, the next step is to **create a Pull Request (PR)**. A **Pull Request** is how you propose your changes to be merged into another branch — typically the `main` branch. + + + +
+ +It’s also where discussions, reviews, and collaboration happen before merging your work. + +## What is a Pull Request? + +A **Pull Request** (PR) allows you to tell others about changes you’ve pushed to a branch in a GitHub repository. When you open a PR, you’re asking the repository maintainer to review your code and merge it into the main codebase. + +:::tip Think of a pull request as saying + +Hey, I’ve made some improvements. Can you check and merge them? + +::: + +## Step-by-Step: How to Create a Pull Request on GitHub + +### 1. Push your branch to GitHub + +Before you can open a pull request, make sure your branch is already pushed to GitHub. + +```bash +git push origin feature/add-readme +``` + +### 2. Go to your repository on GitHub + +Open your repository in your browser, e.g.: +`https://github.com//` + +GitHub will often display a yellow bar like this: + +> **Compare & pull request** – You’ve recently pushed a branch. + +Click on **Compare & pull request**. + + + +
+ +### 3. Choose branches to compare + +You’ll see two dropdowns: + +- **base:** usually `main` (where you want your changes to go) +- **compare:** your feature branch (the one containing your new commits) + +Example: + +``` +base: main ← compare: feature/add-readme +``` + +### 4. Write a clear pull request title and description + +Add a meaningful title and a short description of your changes. + +Example: + +**Title:** +`Added a detailed README with setup instructions` + +**Description:** + +``` +### What’s new +* Added a comprehensive README file +*-* Included setup, usage, and contribution guide + +### Why +To help new contributors get started quickly. +``` + +This helps reviewers understand your contribution at a glance. + +### 5. Review your changes + +Scroll down to see all the files changed. Make sure your commits reflect what you actually want to merge — and nothing extra. + +### 6. Create the Pull Request + +Click on **Create Pull Request** 🎉 Your PR is now open! + +It will appear under the repository’s **Pull Requests** tab, where reviewers can: + +- Comment on your changes +- Suggest edits +- Approve or request modifications + + + +
+ +## 7. Review Process + +Once you submit your PR: + +- Reviewers may leave comments asking for clarification or improvements +- You can make more commits to your branch, and they’ll automatically appear in the same PR +- When everything looks good, the maintainer will **merge** your PR into the base branch + +## 8. Merge the Pull Request + +Once approved, the PR can be merged. If you have permission, click: + +> **Merge Pull Request** → **Confirm Merge** + +After merging, delete your branch to keep the repository clean: + +```bash +git branch -d feature/add-readme +``` + +## Example Workflow Summary + +```bash +# Create a new branch +git checkout -b feature/add-readme + +# Make changes +git add . +git commit -m "Added detailed README" + +# Push to GitHub +git push origin feature/add-readme + +# Open PR on GitHub website +# base: main ← compare: feature/add-readme +``` + +## Best Practices for Pull Requests + +* Keep PRs small and focused — easier to review +* Write clear titles and meaningful commit messages +* Add screenshots if your change affects the UI +* Reference related issues using `Fixes #issue-number` +* Respond to review comments promptly + + + +
+ +## Summary + +You’ve learned how to: + +* Understand what a Pull Request is +* Create and open a PR on GitHub +* Write a good title and description +* Collaborate and merge your changes + +--- + +Need help? Ask your questions or share your first PR experience in the [GitHub Discussions](https://github.com/orgs/codeharborhub/discussions/categories/introduction-to-github). We’d love to hear from you and help you grow as a contributor \ No newline at end of file diff --git a/docs/github/img-1.png b/docs/github/img-1.png new file mode 100644 index 0000000..a8eb589 Binary files /dev/null and b/docs/github/img-1.png differ diff --git a/docs/github/img-10.png b/docs/github/img-10.png new file mode 100644 index 0000000..5f6dbbe Binary files /dev/null and b/docs/github/img-10.png differ diff --git a/docs/github/img-11.png b/docs/github/img-11.png new file mode 100644 index 0000000..2305e64 Binary files /dev/null and b/docs/github/img-11.png differ diff --git a/docs/github/img-12.png b/docs/github/img-12.png new file mode 100644 index 0000000..53d8dbe Binary files /dev/null and b/docs/github/img-12.png differ diff --git a/docs/github/img-13.png b/docs/github/img-13.png new file mode 100644 index 0000000..0971725 Binary files /dev/null and b/docs/github/img-13.png differ diff --git a/docs/github/img-14.png b/docs/github/img-14.png new file mode 100644 index 0000000..39fd27d Binary files /dev/null and b/docs/github/img-14.png differ diff --git a/docs/github/img-15.png b/docs/github/img-15.png new file mode 100644 index 0000000..9ea85b6 Binary files /dev/null and b/docs/github/img-15.png differ diff --git a/docs/github/img-16.png b/docs/github/img-16.png new file mode 100644 index 0000000..588ea44 Binary files /dev/null and b/docs/github/img-16.png differ diff --git a/docs/github/img-17.png b/docs/github/img-17.png new file mode 100644 index 0000000..e43acf8 Binary files /dev/null and b/docs/github/img-17.png differ diff --git a/docs/github/img-2.png b/docs/github/img-2.png new file mode 100644 index 0000000..5ec3f0d Binary files /dev/null and b/docs/github/img-2.png differ diff --git a/docs/github/img-3.png b/docs/github/img-3.png new file mode 100644 index 0000000..2647eb0 Binary files /dev/null and b/docs/github/img-3.png differ diff --git a/docs/github/img-4.png b/docs/github/img-4.png new file mode 100644 index 0000000..5c52bcf Binary files /dev/null and b/docs/github/img-4.png differ diff --git a/docs/github/img-5.png b/docs/github/img-5.png new file mode 100644 index 0000000..7092f06 Binary files /dev/null and b/docs/github/img-5.png differ diff --git a/docs/github/img-6.png b/docs/github/img-6.png new file mode 100644 index 0000000..2089397 Binary files /dev/null and b/docs/github/img-6.png differ diff --git a/docs/github/img-7.png b/docs/github/img-7.png new file mode 100644 index 0000000..8f42760 Binary files /dev/null and b/docs/github/img-7.png differ diff --git a/docs/github/img-8.png b/docs/github/img-8.png new file mode 100644 index 0000000..62957e1 Binary files /dev/null and b/docs/github/img-8.png differ diff --git a/docs/github/img-9.png b/docs/github/img-9.png new file mode 100644 index 0000000..f3bb5e3 Binary files /dev/null and b/docs/github/img-9.png differ diff --git a/docs/github/introduction-to-github.md b/docs/github/introduction-to-github.md new file mode 100644 index 0000000..dde8a92 --- /dev/null +++ b/docs/github/introduction-to-github.md @@ -0,0 +1,45 @@ +--- +id: introduction-to-github +title: Introduction to GitHub +sidebar_label: Introduction to GitHub +sidebar_position: 1 +description: "Get started with GitHub in less than an hour! Learn the basics of Git and GitHub, create a new repository, clone a repository, create a branch, make changes to a file, commit changes, push changes to GitHub, create a pull request, and merge a pull request." +tags: [github, git, version control, collaboration, open source, beginners] +keywords: [github, git, version control, collaboration, open source, repository, branch, commit, pull request, merge, beginners] +--- + +Welcome to the Introduction to GitHub tutorial! This tutorial is designed to help you get started with GitHub and learn the basics of Git and GitHub. + + + +
+ +## What you'll learn + +- Create a new repository +- Clone a repository +- Create a branch +- Make changes to a file +- Commit changes +- Push changes to GitHub +- Create a pull request +- Merge a pull request +- And more! + +## Why learn GitHub? + +GitHub is a platform that brings people together to work on projects from all over the world. It is a powerful tool for collaboration, version control, and open-source development. Learning GitHub can help you become a better developer, work on exciting projects, and contribute to the open-source community. + +## Prerequisites + +This tutorial is designed for beginners, so no prior knowledge of Git or GitHub is required. All you need is a GitHub account and a computer with an internet connection. + +## Let's get started! + +Now that you know what to expect from this course, let's get started with the first lesson: [Create a GitHub account](/tutorial/github/create-a-github-account). If you already have a GitHub account, you can skip this step and move on to the next lesson. + +[![start-course](https://user-images.githubusercontent.com/1221423/235727646-4a590299-ffe5-480d-8cd5-8194ea184546.svg)](https://github.com/new?template_owner=ajay-dhangar&template_name=introduction-to-github&owner=%40me&name=skills-introduction-to-github&description=My+clone+repository&visibility=public) + +Click on the button above to create a new repository and start the tutorial. You can use this repository to follow along with the practice what you learn. + +If you have any questions or need help, feel free to ask in the [GitHub Discussions](https://github.com/orgs/codeharborhub/discussions/categories/introduction-to-github) for this course. We're here to help you succeed! \ No newline at end of file diff --git a/docs/github/make-changes-to-a-file.md b/docs/github/make-changes-to-a-file.md new file mode 100644 index 0000000..cc7a641 --- /dev/null +++ b/docs/github/make-changes-to-a-file.md @@ -0,0 +1,78 @@ +--- +id: make-changes-to-a-file +title: Make Changes to a File +sidebar_label: Make Changes to a File +sidebar_position: 6 +description: Learn how to make changes to a file in a Git repository. Edit files, add new content, and update existing code in your project. +tags: [github, git, version control, collaboration, beginners] +keywords: + [ + github, + git, + version control, + collaboration, + beginners, + open source, + edit, + file, + changes, + update, + content, + ] +--- + +**To make changes to a file in a Git repository, you need to edit the file, add new content, or update existing code. Making changes to files allows you to improve your project, fix bugs, and add new features.** + + + +
+ +To make changes to a file in a Git repository, follow these steps: + +1. Open the file you want to edit in your code editor. You can use popular code editors like VS Code or any other editor of your choice. + +2. Make the necessary changes to the file. You can add new content, update existing code, fix bugs, or make improvements to the file. + +3. Save the changes to the file. Use the `Save` or `Save As` option in your code editor to save the changes you made. + +4. Verify the changes by reviewing the file. Check if the changes are correct, well-formatted, and meet the requirements of your project. + +5. Stage the changes using the `git add` command. This command adds the changes to the staging area, preparing them for the next commit. + + ```bash title="Terminal" + git add filename + ``` + + :::tip Note: + Replace `filename` with the name of the file you want to stage. You can also use `git add .` to stage all changes in the repository. + ::: + +6. Commit the changes using the `git commit` command. This command creates a new commit with the changes you staged in the previous step. + + ```bash title="Terminal" + git commit -m "Add new feature to the project" + ``` + + :::tip Note: + Replace `"Add new feature to the project"` with a meaningful commit message that describes the changes you made in this commit. + ::: + + + +
+ +7. Push the changes to GitHub using the `git push` command. This command uploads the commits to the remote repository on GitHub. + + ```bash title="Terminal" + git push origin branch-name + ``` + + :::tip Note: + Replace `branch-name` with the name of the branch you are working on. By default, the branch name is `main` or `master`. + ::: + +8. Verify the changes on GitHub by visiting the repository on the GitHub website. You should see the new commit with the changes you made to the file. + +9. Congratulations! You have successfully made changes to a file in a Git repository and pushed the changes to GitHub. Keep up the good work! + +By following these steps, you can make changes to files in your Git repository, collaborate with others, and contribute to open-source projects. Keep practicing and learning to become a better developer! diff --git a/docs/github/merge-a-pull-request.md b/docs/github/merge-a-pull-request.md new file mode 100644 index 0000000..b9e1db9 --- /dev/null +++ b/docs/github/merge-a-pull-request.md @@ -0,0 +1,152 @@ +--- +id: merge-a-pull-request +title: Merge a Pull Request +sidebar_label: Merge a Pull Request +sidebar_position: 10 +description: "Learn how to merge a pull request (PR) on GitHub after code review, understand different merge methods, and clean up branches after merging." +tags: [github, git, pull request, merge, collaboration, beginners, open source] +keywords: [merge pull request, github merge, git merge, merge branch, github pr workflow, beginners guide] +--- + +After creating and reviewing a **Pull Request (PR)**, the final step in the GitHub workflow is to **merge it** into the main branch. Merging means integrating your feature branch changes into the base branch — typically `main`. + +Once merged, your updates officially become part of the project 🎉 + + + +
+ +## What Does “Merging” Mean? + +In Git and GitHub, **merging** takes the changes from one branch (like `feature/update-ui`) and integrates them into another branch (like `main`). +When you merge a PR, Git combines the commit histories and updates the target branch with your new code. + +## Step-by-Step: How to Merge a Pull Request + +### 1. Go to the Pull Requests tab + +Navigate to your repository on GitHub and click on the **Pull requests** tab. +You’ll see a list of open PRs. + +Example: +`https://github.com///pulls` + +### 2. Select the Pull Request you want to merge + +Click on the PR you created earlier (for example: `Added detailed README`). +Here, you’ll see: + +- The PR title and description +- Files changed +- Review comments +- Merge status + + + +
+ +### 3. Review the Merge Status + +GitHub automatically checks if the PR can be merged cleanly. +You’ll see one of these messages: + +* ✅ **This branch has no conflicts with the base branch** – safe to merge +* ⚠️ **This branch has conflicts that must be resolved** – fix before merging + +If there are conflicts, click **Resolve conflicts**, fix them in the web editor, and commit the changes. + +### 4. Choose a Merge Method + +GitHub provides three main merge options: + +| Merge Option | Description | When to Use | +|---------------|--------------|--------------| +| **Merge Commit** | Adds all commits from the feature branch into the base branch with a single merge commit | Default, keeps full history | +| **Squash and Merge** | Combines all commits from the branch into one clean commit | Best for small feature updates or fixes | +| **Rebase and Merge** | Rewrites the commit history, placing your commits on top of the base branch | For maintaining a linear history | + +Example (default): + +> ✅ **Merge pull request #3 from feature/add-readme** + +### 5. Confirm the Merge + +Once you’ve chosen a method, click: **Merge Pull Request → Confirm Merge** + +GitHub will integrate your changes and show a success message: + +> 🎉 Pull request successfully merged and closed! + +### 6. Delete the Branch (Optional but Recommended) + +After merging, it’s a good practice to delete your feature branch — it keeps your repository clean. Click **Delete branch** on GitHub or run this locally: + +```bash +git branch -d feature/add-readme +``` + +If you want to delete the remote branch as well: + +```bash +git push origin --delete feature/add-readme +``` + + + +
+ +## Example Workflow Summary + +Here’s a full merge process from start to finish: + +```bash +# 1. Create a new branch +git checkout -b feature/add-readme + +# 2. Make changes and commit +git add . +git commit -m "Added detailed README file" + +# 3. Push branch to GitHub +git push origin feature/add-readme + +# 4. Create a Pull Request on GitHub +# 5. Review → Merge Pull Request +# 6. Delete the feature branch +``` + +## Troubleshooting Common Merge Issues + +| Problem | Cause | Solution | +|----------|--------|----------| +| Merge conflicts | Both branches edited the same file | Resolve conflicts manually, then commit | +| Accidental merge to wrong branch | Wrong base selected | Revert the PR and recreate with correct base | +| Too many commits | Long commit history | Use “Squash and Merge” for a cleaner log | + +--- + +:::tip + +* Always pull the latest `main` branch before merging +* Use descriptive PR titles for better project history +* Use “Squash and Merge” for small, single-purpose PRs +* Delete merged branches to reduce clutter + +::: + +## Summary + +You’ve learned how to: + +- Review and merge pull requests on GitHub +- Understand merge options (merge, squash, rebase) +- Handle conflicts before merging +- Clean up branches after merging + +This marks the **completion of your GitHub journey** — from creating repositories to collaborating and merging code. + +--- + +**Need help or want to share your first merged PR?** + +Join the [GitHub Discussions](https://github.com/orgs/codeharborhub/discussions/categories/introduction-to-github) community — we’d love to see your progress and support you on your journey \ No newline at end of file diff --git a/docs/github/push-changes-to-github.md b/docs/github/push-changes-to-github.md new file mode 100644 index 0000000..784ed6e --- /dev/null +++ b/docs/github/push-changes-to-github.md @@ -0,0 +1,147 @@ +--- +id: push-changes-to-github +title: Push Changes to GitHub +sidebar_label: Push Changes to GitHub +sidebar_position: 8 +description: "Learn how to push your local commits to a remote repository on GitHub. Understand the difference between local and remote repositories and how to keep them in sync." +tags: [github, git, push, commits, repository, beginners, version control] +keywords: [push changes, github push, git push origin main, remote repository, sync local and remote, beginners guide] +--- + +Once you’ve made and committed changes to your local repository, the next step is to share those updates with your remote repository on **GitHub**. This process is known as **pushing** changes. + +Pushing ensures your latest work is uploaded to GitHub so that you (and your team) can access it from anywhere. + + + +
+ +## What is "Push" in Git? + +The **push** command in Git uploads your local commits to a remote repository. Think of it as “publishing” your changes to GitHub. + +```bash +git push +``` + +When you run this command, Git sends your local branch’s commits to the corresponding branch in your remote repository (for example, `main` or `master`). + +## Step-by-Step: How to Push Changes to GitHub + +### 1. Check your current branch + +Before pushing, make sure you’re on the correct branch. + +```bash +git branch +``` + +If you’re on a feature branch (e.g., `feature/update-readme`), Git will push that branch to the remote repository. + +### 2. Link your local repository to a remote (if not already) + +If your local repo isn’t connected to GitHub yet, add the remote URL: + +```bash +git remote add origin https://github.com//.git +``` + +Then verify it: + +```bash +git remote -v +``` + +You should see something like: + +``` +origin https://github.com/ajay-dhangar/introduction-to-github.git (fetch) +origin https://github.com/ajay-dhangar/introduction-to-github.git (push) +``` + + + +
+ +### 3. Push your changes + +Now that your repository is ready, push your commits using: + +```bash +git push origin main +``` + +or, if you’re working on a branch: + +```bash +git push origin your-branch-name +``` + +**Example:** + +```bash +git push origin feature/add-login-form +``` + +This command uploads all your local commits from the branch `feature/add-login-form` to GitHub. + +--- + +### 4. Enter your GitHub credentials (if prompted) + +If it’s your first time pushing, Git may ask for your GitHub username and a **Personal Access Token (PAT)** instead of your password. + +You can create one by visiting: 👉 [GitHub Personal Access Tokens](https://github.com/settings/tokens) + +### 5. Verify your changes on GitHub + +After a successful push, go to your repository on GitHub — you’ll see your commits reflected there + +You can also check the commit history: + +```bash +git log +``` + + + +
+ +## Common Errors and Fixes + +| Issue | Cause | Fix | +|-------|--------|-----| +| `error: failed to push some refs` | Your local branch is behind the remote branch | Run `git pull origin main --rebase` before pushing again | +| `authentication failed` | Invalid credentials or expired token | Generate a new PAT and reauthenticate | +| `remote: Repository not found` | Wrong remote URL | Double-check the repo name and your GitHub username | + +:::tip + +If you want Git to remember your remote branch for next time, you can use the `-u` flag: + +```bash +git push -u origin main +``` + +Now, you can simply run: + +```bash +git push +``` + +from then on — Git will automatically know where to push your changes. + +::: + +## Summary + +You’ve learned how to: + +- Understand what “push” means in Git +- Connect a local repository to a remote one +- Push your commits to GitHub +- Handle common push errors + +--- + +Need help? Ask your questions in the [GitHub Discussions](https://github.com/orgs/codeharborhub/discussions/categories/introduction-to-github). We’re here to help you grow as a contributor \ No newline at end of file diff --git a/docs/index.mdx b/docs/index.mdx index d259dfa..6d2bdb2 100644 --- a/docs/index.mdx +++ b/docs/index.mdx @@ -2,7 +2,6 @@ title: Welcome to CodeHarborHub sidebar_position: 1 slug: / -hide_table_of_contents: true --- Hello, and welcome to CodeHarborHub! Our mission is to provide accessible and comprehensive educational resources to learners of all levels, from beginners to advanced professionals. Whether you're looking to kickstart your career in web development, master a new programming language, or stay updated on the latest tech trends, we've got you covered. diff --git a/docs/react/_category_.json b/docs/react/_category_.json index 6f7bf74..0bb10f5 100644 --- a/docs/react/_category_.json +++ b/docs/react/_category_.json @@ -1,6 +1,6 @@ { "label": "React", - "position": 22, + "position": 7, "link": { "type": "generated-index", "description": "React is a JavaScript library for building user interfaces. It is maintained by Facebook and a community of individual developers and companies." diff --git a/docusaurus.config.js b/docusaurus.config.js index 3bdfdf7..1135ec2 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -135,7 +135,7 @@ const config = { { type: "html", value: `