Skip to content

Commit e3d228a

Browse files
committed
conflict merge
2 parents ac3e93c + 0df9611 commit e3d228a

File tree

6 files changed

+188
-34
lines changed

6 files changed

+188
-34
lines changed

public/posts/index.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[
2+
{
3+
"title": "pull_request_tutorial_for_beginners"
4+
}
5+
]
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
Pull requests (PRs) are a crucial part of collaborative software development, especially in open-source projects. They allow developers to propose changes to a codebase, which can then be reviewed and discussed by others before being merged. This tutorial will guide you through the process of creating a pull request.
2+
3+
## Prerequisites
4+
5+
- Basic knowledge of Git and GitHub.
6+
- A GitHub account.
7+
- Git installed on your computer.
8+
9+
## Step 1: Fork the Repository
10+
11+
1. Navigate to the repository you want to contribute to on GitHub.
12+
2. Click the "Fork" button at the top right of the page. This will create a copy of the repository under your GitHub account.
13+
14+
## Step 2: Clone Your Fork
15+
16+
Clone the forked repository to your local machine:
17+
18+
```bash
19+
git clone https://github.com/your-username/repository-name.git
20+
```
21+
Replace your-username with your GitHub username and repository-name with the name of the repository.
22+
23+
24+
## Step 3: Create a New Branch
25+
26+
Navigate into the cloned repository:
27+
28+
```bash
29+
cd repository-name
30+
```
31+
32+
Create and switch to a new branch for your changes:
33+
```bash
34+
git checkout -b feature-branch-name
35+
```
36+
37+
Choose a descriptive name for your branch, such as fix-bug-123 or add-feature-xyz.
38+
39+
## Step 4: Make Your Changes
40+
41+
Make the necessary changes to the codebase. You can use any code editor of your choice.
42+
43+
## Step 5: Commit Your Changes
44+
45+
```bash
46+
git add .
47+
git commit -m "Brief description of your changes"
48+
```
49+
50+
Write a clear and concise commit message that describes what you have done.
51+
52+
## Step 6: Push Your Changes
53+
54+
Push your changes to your forked repository:
55+
56+
```bash
57+
git push origin feature-branch-name
58+
```
59+
60+
## Step 7: Create a Pull Request
61+
62+
1. Go to your forked repository on GitHub.
63+
2. You should see a banner suggesting to compare & pull request. Click on it. If not, navigate to the "Pull requests" tab and click "New pull request."
64+
3. Make sure the base repository is the original repository and the base branch is where you want to merge your changes (usually main or master).
65+
4. The compare branch should be the branch you pushed your changes to.
66+
5. Write a title and description for your pull request. Provide details on what changes you made and why.
67+
6. Click "Create pull request."
68+
69+
## Step 8: Address Feedback
70+
71+
Once your pull request is created, other contributors or maintainers may review it and leave feedback. Be prepared to make additional changes based on this feedback.
72+
73+
**To make changes:**
74+
1. Make the required changes on your local branch.
75+
2. Commit and push the changes:
76+
```bash
77+
git add .
78+
git commit -m "Addressed feedback on XYZ"
79+
git push origin feature-branch-name
80+
```
81+
The pull request will automatically update with your new commits.
82+
83+
## Step 9: Merge the Pull Request
84+
85+
Once your pull request has been approved, a maintainer will merge it into the base branch. In some projects, you may have permission to merge it yourself.
86+
87+
## Step 10: Clean Up
88+
89+
After your pull request has been merged, you can clean up your local repository by deleting the branch:
90+
91+
```bash
92+
git checkout main
93+
git pull origin main
94+
git branch -d feature-branch-name
95+
```
96+
```javascript
97+
98+
useEffect(() => {
99+
const fetchDocs = async () => {
100+
try {
101+
const response = await fetch('/posts/index.json');
102+
if (!response.ok) {
103+
throw new Error('Network response was not ok');
104+
}
105+
const data = await response.json();
106+
setDocs(data);
107+
} catch (error) {
108+
setError(error.message);
109+
} finally {
110+
setLoading(false);
111+
}
112+
};
113+
114+
fetchDocs();
115+
}, []);
116+
117+
```
118+
You may also delete the branch from your fork on GitHub.
119+
120+
Congratulations! You've successfully created and merged a pull request. This process helps maintain code quality and encourages collaboration among developers.
121+
122+
This tutorial covers the basics of creating a pull request and includes best practices to help beginners understand the process.

src/data/error.json

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"description": "error: failed to push some refs to 'github.com:user/repo.git'",
1313
"solutions": "rm -rf .git<git init<git add .<git commit -m \"ges\"<git branch -M main<git remote add origin YOUR_GITHUB_REPO_LINK<git push -u origin main -f"
1414
},
15-
1615
{
1716
"type": "merge",
1817
"title": "fatal: refusing to merge unrelated histories",
@@ -25,7 +24,7 @@
2524
"description": "Unable to add file. While adding file, it shows fatal: not a valid object name: 'master'.",
2625
"solutions": "git commit -m \"first commit\""
2726
},
28-
{
27+
{
2928
"type": "add",
3029
"title": "Another git process seems to be running in this repository",
3130
"description": "Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file manually to continue.",
@@ -43,13 +42,19 @@
4342
"description": "Can't switch/checkout to the BRANCH, bcz this branch is not exits man!",
4443
"solutions": "This branch is not there, you have to create this branch. < git branch BRANCHNAME -m"
4544
},
45+
{
46+
"type": "branch",
47+
"title": "error: bad signature 0x00000000",
48+
"description": "Can't switch/checkout to the BRANCH, fatal: index file corrupt!",
49+
"solutions": "rm .git/index < git reset"
50+
},
4651
{
4752
"type": "add",
4853
"title": "error: Your local changes to the following files would be overwritten by checkout: <file name>",
4954
"description": "Please commit your changes or stash them before you stwitch branches. Aborting",
5055
"solutions": "rm -f .git/index.lock"
5156
},
52-
{
57+
{
5358
"type": "commit",
5459
"title": "error: Your local changes to the following files would be overwritten by checkout: <file name>",
5560
"description": "Please commit your changes or stash them before you stwitch branches. Aborting",
@@ -61,7 +66,7 @@
6166
"description": "fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.",
6267
"solutions": "git pull origin BRANCHNAME"
6368
},
64-
{
69+
{
6570
"type": "pull",
6671
"title": "fatal: refusing to merge unrelated histories",
6772
"description": "The refusing to merge unrelated histories error typically occurs when Git detects that the branches you are trying to merge have divergent commit histories and are essentially unrelated.",
@@ -98,17 +103,17 @@
98103
"solutions": "git pull"
99104
},
100105
{
101-
"type": "branch",
102-
"title": "Delete Local branch",
103-
"description": "You can easily delete a local branch. If the branch has not been merged, use git branch -d <branchname> instead.",
104-
"solutions": "git branch --delete [branchname]"
105-
},
106-
{
107-
"type": "pull",
108-
"title": "Pulling issue",
109-
"description": "error: bad signature 0x00000000, fatal: index file corrupt. NB: use git bash for this command. if you use cmd then use del instead of rm.",
110-
"solutions": "rm -f .git/index<git reset"
111-
},
106+
"type": "branch",
107+
"title": "Delete Local branch",
108+
"description": "You can easily delete a local branch. If the branch has not been merged, use git branch -d <branchname> instead.",
109+
"solutions": "git branch --delete [branchname]"
110+
},
111+
{
112+
"type": "pull",
113+
"title": "Pulling issue",
114+
"description": "error: bad signature 0x00000000, fatal: index file corrupt. NB: use git bash for this command. if you use cmd then use del instead of rm.",
115+
"solutions": "rm -f .git/index<git reset"
116+
},
112117
{
113118
"type": "push",
114119
"title": "remote: Not Found",
@@ -308,16 +313,16 @@
308313
"solutions": "git status"
309314
},
310315
{
311-
"type":"cmd",
312-
"title":"error: RPC failed; curl transfer closed with outstanding read data remaining",
313-
"description":"typically occurs when Git is unable to complete a network request, often due to a slow or unstable connection or Small HTTPS Buffer on Client machine",
314-
"solutions":" increasing the Git buffer size and using a different network connection are two possible solutions that may help resolve the issue < git config http.postBuffer 524288000 < git config --global http.maxRequestBuffer 524288000 < git config --global core.compression 0"
316+
"type": "cmd",
317+
"title": "error: RPC failed; curl transfer closed with outstanding read data remaining",
318+
"description": "typically occurs when Git is unable to complete a network request, often due to a slow or unstable connection or Small HTTPS Buffer on Client machine",
319+
"solutions": " increasing the Git buffer size and using a different network connection are two possible solutions that may help resolve the issue < git config http.postBuffer 524288000 < git config --global http.maxRequestBuffer 524288000 < git config --global core.compression 0"
315320
},
316-
{
321+
{
317322
"type": "commit",
318323
"title": "Git nothing to commit",
319324
"description": "The Git command line informs us that our local repository contains one more commit than our remote repository.",
320325
"solutions": "git push"
321326
}
322327
]
323-
}
328+
}

src/index.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/pages/Doc/index.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ const DocList = () => {
1111
useEffect(() => {
1212
const fetchDocs = async () => {
1313
try {
14-
const response = await fetch('/posts/index.json');
14+
// const response = await fetch('/posts/index.json');
15+
const response = await fetch('https://github-error-solve.vercel.app/posts/index.json');
1516
if (!response.ok) {
16-
throw new Error('Network response was not ok');
17+
throw new Error(`HTTP error! status: ${response.status}`);
1718
}
1819
const data = await response.json();
1920
setDocs(data);
2021
} catch (error) {
2122
setError(error.message);
23+
console.error("Error fetching JSON data:", error);
2224
} finally {
2325
setLoading(false);
2426
}
@@ -27,6 +29,8 @@ const DocList = () => {
2729
fetchDocs();
2830
}, []);
2931

32+
33+
3034
if (loading) return <div className="flex justify-center items-center h-screen"><Spin size="large" /></div>;
3135
if (error) return <Alert message="Error" description={error} type="error" />;
3236

src/pages/Doc/single doc/index.jsx

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from 'react';
1+
import React, { useEffect, useRef, useState } from 'react';
22
import { useParams } from 'react-router-dom';
33
import ReactMarkdown from 'react-markdown';
44
import remarkGfm from 'remark-gfm';
@@ -13,6 +13,20 @@ const DocDetail = () => {
1313
const [loading, setLoading] = useState(true);
1414
const [error, setError] = useState(null);
1515
const [headings, setHeadings] = useState([]);
16+
const tableRef = useRef(null);
17+
18+
useEffect(() => {
19+
const handleScroll = () => {
20+
if (tableRef.current) {
21+
const rect = tableRef.current.getBoundingClientRect();
22+
const isTableVisible = rect.top <= 0 && rect.bottom >= 100;
23+
setIsSticky(isTableVisible);
24+
}
25+
};
26+
27+
window.addEventListener('scroll', handleScroll);
28+
return () => window.removeEventListener('scroll', handleScroll);
29+
}, []);
1630

1731
useEffect(() => {
1832
const fetchContent = async () => {
@@ -33,7 +47,6 @@ const DocDetail = () => {
3347
fetchContent();
3448
}, [slug]);
3549

36-
3750
const extractHeadings = (markdown) => {
3851
const headings = [];
3952
const regex = /^#{1,6}\s+(.*)$/gm;
@@ -53,8 +66,9 @@ const DocDetail = () => {
5366
}, [content]);
5467

5568
useEffect(() => {
56-
if (window.location.hash) {
57-
const id = window.location.hash.substring(1);
69+
const hash = window.location.hash;
70+
if (hash) {
71+
const id = hash.substring(1);
5872
const element = document.getElementById(id);
5973
if (element) {
6074
element.scrollIntoView({ behavior: 'smooth' });
@@ -67,17 +81,20 @@ const DocDetail = () => {
6781

6882
return (
6983
<Layout>
70-
<section className="container mx-auto p-4">
84+
<section className="container mx-auto p-4 min-h-screen">
7185
<h3 className="text-2xl md:text-3xl capitalize text-center my-10 mb-20 font-semibold">
7286
{slug.replace(/-/g, ' ')}
7387
</h3>
74-
<div className="flex sticky top-20">
75-
<aside className="w-1/4 p-4">
88+
<div className="flex">
89+
<aside ref={tableRef} className="sticky top-20 w-1/4 p-4 h-0">
7690
<h2 className="text-xl font-bold mb-2">Table of Contents</h2>
7791
<ul>
7892
{headings.map((heading, index) => (
7993
<li key={index} className={`ml-${heading.level}`}>
80-
<a href={`#${heading.title.replace(/\s+/g, '-').toLowerCase()}`}>
94+
<a href={`#${heading.title.replace(/\s+/g, '-').toLowerCase()}`}
95+
96+
onClick={() => console.log(heading.title.replace(/\s+/g, '-').toLowerCase())}
97+
>
8198
{heading.title}
8299
</a>
83100
</li>
@@ -106,13 +123,13 @@ const DocDetail = () => {
106123
);
107124
},
108125
h1({ node, children }) {
109-
return <h1 className='text-xl font-normal mt-5' id={children[0].toLowerCase().replace(/\s+/g, '-')}> {children}</h1>;
126+
return <h1 className='text-xl font-normal mt-10 mb-3' id={children.toLowerCase().replace(/\s+/g, '-')}> {children}</h1>;
110127
},
111128
h2({ node, children }) {
112-
return <h2 className='text-xl font-normal mt-5' id={children[0].toLowerCase().replace(/\s+/g, '-')}>🌿 {children}</h2>;
129+
return <h2 className='text-xl font-normal mt-10 mb-3' id={children.toLowerCase().replace(/\s+/g, '-')}>🌿 {children}</h2>;
113130
},
114131
h3({ node, children }) {
115-
return <h3 className='text-xl font-normal mt-5' id={children[0].toLowerCase().replace(/\s+/g, '-')}>🌿 {children}</h3>;
132+
return <h3 className='text-xl font-normal mt-10 mb-3' id={children.toLowerCase().replace(/\s+/g, '-')}>🌿 {children}</h3>;
116133
},
117134
// Handle other heading levels if needed
118135
}}

0 commit comments

Comments
 (0)