Skip to content

Commit 6aaf3e7

Browse files
authored
Merge pull request #4374 from CodeHarborHub/dev-3
added new docs in GitHub Course
2 parents f10f493 + 2967180 commit 6aaf3e7

File tree

9 files changed

+151
-3
lines changed

9 files changed

+151
-3
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
id: clone-a-repository
3+
title: Clone a Repository
4+
sidebar_label: Clone a Repository
5+
sidebar_position: 4
6+
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.
7+
tags: [github, git, version control, collaboration, beginners]
8+
keywords: [github, git, version control, collaboration, beginners, open source, repository, clone, project]
9+
---
10+
11+
**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.**
12+
13+
14+
To clone a repository from GitHub, follow these steps:
15+
16+
1. Go to [GitHub](https://github.com/) and log in to your account. After logging in, you will see your GitHub dashboard.
17+
18+
<BrowserWindow url="https://github.com/chh-user" bodyStyle={{ padding: 0 }}>
19+
![GitHub Login](img-12.png)
20+
</BrowserWindow>
21+
22+
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.
23+
24+
<BrowserWindow url="https://github.com/chh-user?tab=repositories" bodyStyle={{ padding: 0 }}>
25+
![Repository List](img-13.png)
26+
</BrowserWindow>
27+
28+
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.
29+
30+
<BrowserWindow url="https://github.com/chh-user/hello-world" bodyStyle={{ padding: 0 }}>
31+
![Repository Main Page](img-14.png)
32+
</BrowserWindow>
33+
34+
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.
35+
36+
<BrowserWindow url="https://github.com/chh-user/hello-world" bodyStyle={{ padding: 0 }}>
37+
![Code Download Options](img-15.png)
38+
</BrowserWindow>
39+
40+
5. Copy the HTTPS URL of the repository. You will use this URL to clone the repository to your local machine.
41+
42+
<BrowserWindow url="https://github.com/chh-user/hello-world" bodyStyle={{ padding: 0 }}>
43+
![HTTPS URL](img-16.png)
44+
</BrowserWindow>
45+
46+
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.
47+
48+
```bash title="Terminal"
49+
cd path/to/directory
50+
```
51+
52+
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.
53+
54+
:::tip Note:
55+
Replace `chh-user` with the **username** of the repository owner and `hello-world` with the name of the repository you want to clone.
56+
:::
57+
58+
```bash title="Terminal"
59+
git clone https://github.com/chh-user/hello-world.git
60+
```
61+
62+
![alt text](img-17.png)
63+
64+
65+
8. After cloning the repository, you can navigate to the project directory using the `cd` command.
66+
67+
```bash title="Terminal"
68+
cd hello-world
69+
```
70+
71+
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.
72+
73+
```pwsh
74+
# Make changes to the code
75+
# Add new features
76+
# Fix bugs
77+
# Push changes back to GitHub
78+
```
79+
80+
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! 🚀

courses/github/create-a-branch.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
id: create-a-branch
3+
title: Create a Branch
4+
sidebar_label: Create a Branch
5+
sidebar_position: 5
6+
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.
7+
tags: [github, git, version control, collaboration, beginners]
8+
keywords: [github, git, version control, collaboration, beginners, open source, branch, create, new, feature, bug fix]
9+
---
10+
11+
**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.**
12+
13+
:::caution Prerequisites
14+
- 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)**.
15+
- Always create a new branch for each new feature, bug fix, or experiment to keep your codebase clean and organized.
16+
- 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/)**.
17+
- 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.
18+
:::
19+
20+
To create a new branch in a Git repository, follow these steps:
21+
22+
1. Open VS Code and open the project you want to create a branch in.
23+
24+
2. Open the terminal in vs code.
25+
26+
3. Run the following command to create a new branch. Replace `branch-name` with the name of your new branch.
27+
28+
```bash title="Terminal"
29+
git checkout -b branch-name
30+
```
31+
32+
:::tip Note:
33+
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.
34+
:::
35+
36+
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.
37+
38+
5. To switch between branches, use the `git checkout` command followed by the branch name.
39+
40+
```bash title="Terminal"
41+
git checkout main
42+
```
43+
44+
This command will switch to the `main` branch. Replace `main` with the name of the branch you want to switch to.
45+
46+
6. To list all branches in the repository, use the `git branch` command.
47+
48+
```bash title="Terminal"
49+
git branch
50+
```
51+
52+
This command will list all branches in the repository and highlight the current branch with an asterisk (`*`).
53+
54+
7. To delete a branch, use the `git branch -d` command followed by the branch name.
55+
56+
```bash title="Terminal"
57+
git branch -d branch-name
58+
```
59+
60+
This command will delete the specified branch. Be careful when deleting branches, as this action cannot be undone.
61+
62+
8. To push a new branch to GitHub, use the `git push` command followed by the branch name.
63+
64+
```bash title="Terminal"
65+
git push origin branch-name
66+
```
67+
68+
This command will push the new branch to GitHub, allowing you to collaborate with others and share your work.
69+
70+
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.

courses/github/create-a-github-account.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ keywords: [github, git, version control, collaboration, beginners, open source,
1010

1111
**To get started with GitHub, you need to create a GitHub account. If you already have a GitHub account, you can skip this step.**
1212

13-
## Create a GitHub account
14-
1513
To get started with GitHub, you need to create a GitHub account. If you already have a GitHub account, you can skip this step.
1614

1715
1. Go to [GitHub](https://github.com/) and click on the "Sign up" button.
1816

19-
<BrowserWindow url="https://github.com" minHeight={300} bodyStyle={{ padding: 0 }}>
17+
<BrowserWindow url="https://github.com" bodyStyle={{ padding: 0 }}>
2018
![GitHub Sign Up](img-1.png)
2119
</BrowserWindow>
2220

courses/github/img-12.png

58.9 KB
Loading

courses/github/img-13.png

50.5 KB
Loading

courses/github/img-14.png

71.8 KB
Loading

courses/github/img-15.png

82.9 KB
Loading

courses/github/img-16.png

92.4 KB
Loading

courses/github/img-17.png

67.2 KB
Loading

0 commit comments

Comments
 (0)