Lesson 21 / الدرس 21
Forks: contributing to work that is not yours / الـforks: الإسهام في عمل ليس لك
You cannot push to a repository you do not have write access to — which is almost all of them. A fork is your own copy on GitHub, and it is how every outside contribution is made.
لا تستطيع الدفع إلى مستودع لا تملك حق الكتابة فيه — وهي كلها تقريبًا. والـfork نسختك أنت على GitHub، وبه يُقدَّم كل إسهام خارجي.
Everything so far assumed the repository was yours. Now consider the other case: you find a genuine bug in a project you use, or a mistake in its documentation, and you want to fix it. You have no write access, so git push is refused. A fork is your own copy of their repository, on your own account, which you can push to freely.
git push. والنسخة المستقلة (fork) هي نسختك أنت من مستودعهم، على حسابك أنت، وتستطيع الدفع إليها بحرية.1. Fork on GitHub their repo -> your account
2. git clone git@github.com:you/their-project.git
3. git switch -c fix-typo-in-readme
4. ... make the change, commit ...
5. git push -u origin fix-typo-in-readme
6. Open a pull request — FROM your fork's branch, TO their main
Keeping a fork up to date
A fork is a copy taken at one moment; it does not follow the original. Weeks later theirs has moved on and yours has not, and a pull request built on a stale base is harder to merge. The fix is a second remote, conventionally called upstream, pointing at the original.
upstream، يشير إلى الأصل.git remote add upstream git@github.com:their-org/project.git
git remote -v now you have two
git switch main
git fetch upstream
git merge upstream/main bring their newer work into your main
git push and update your fork on GitHub
origin stays your copy and upstream is theirs — a naming convention, not a rule, but one everyone follows. origin نسختك وupstream نسختهم — وهو عرف تسمية لا قاعدة، لكنه عرف يتبعه الجميع.Contributing to a project well
| Before you write anything | Why |
|---|---|
| Read CONTRIBUTING.md | Most projects say exactly how they want changes |
| Check the open issues | Someone may already be working on it |
| Open an issue first, for anything large | They may not want the change at all |
| Match the existing style | A change that looks foreign is harder to accept |
| One change per pull request | Lesson 19 — a big one gets a shallow review |
The third row saves the most time. Writing a large feature and then discovering the maintainers did not want it is a genuinely common and demoralising experience, and one short question beforehand avoids it entirely.
main في fork خاصتك. فهو يعمل، ثم يوقعك: إذ لا تستطيع وهو مفتوح تحديث main من upstream دون إضافة تلك الـcommits إلى الطلب، ولا تستطيع بدء إسهام ثانٍ دون أن تشابكه بالأول. ففرّع دائمًا. وهذا هو السبب العملي لإصرار الدورة كلها عليه، وهو الخطأ الأشيع عند المسهمين لأول مرة.A first contribution does not have to be code. A typo in the documentation, a broken link, an unclear error message, a missing example — all of these are real contributions, all are welcome in most projects, and all take you through the entire process once with almost no risk of being wrong. Doing that once is worth more than reading about it ten times.
upstream عنك — وذلك ما يزال يستحق الفعل باليد.Try it live / جرّب بنفسك
Check yourself / اختبر نفسك
1. Why do you need a fork to contribute to someone else's project?
The pull request goes from a branch on your fork to their main. They merge it into a repository you never had access to.
2.
What is the upstream remote?
upstream؟origin is your copy; upstream is theirs. Fetching from it is how you keep a fork from drifting behind.
origin نسختك؛ وupstream نسختهم. والجلب منه هو كيف تمنع fork من التخلف.
3.
Why should a contribution never come from your fork's main?
main في fork خاصتك؟It works and then traps you. Any new commit on main joins the open request — including ones you pulled from upstream.
main تنضم إلى الطلب المفتوح — بما فيها ما سحبته من upstream.Score / النتيجة: 0 / 3
Your task / مهمتك
Fork a real public repository — something small you actually use, or one of the many projects that keep a "good first issue" list. Set up upstream, branch, and prepare a genuine small improvement: a typo, a broken link, a clearer sentence in the documentation. Whether you open the pull request is up to you; report the fork, the two remotes, the branch and the change, and say what the project's CONTRIBUTING file asked of you.
اعمل fork لمستودع عام حقيقي — شيء صغير تستخدمه فعلًا، أو أحد المشاريع الكثيرة التي تحتفظ بقائمة "good first issue". وجهّز upstream، وفرّع، وأعدّ تحسينًا صغيرًا حقيقيًا: خطأ مطبعي، أو رابط مكسور، أو جملة أوضح في التوثيق. وفتح الـpull request أمر يعود إليك؛ وأبلغ عن الـfork والـremoteين والـbranch والتغيير، وقل ما الذي طلبه منك ملف CONTRIBUTING في المشروع.
- A real fork of a real project fork حقيقي لمشروع حقيقي
- git remote -v showing origin AND upstream git remote -v يُظهر origin وupstream
- A branch, not main branch لا main
- What CONTRIBUTING.md asked for ما طلبه CONTRIBUTING.md