التحكم في الإصدارات (Version control)
في هذه الصفحة 8 موضوعات
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
نظرة عامة
الموضوعات
- المستودع (Repository)
- الـ commits
- منطقة التجهيز (staging)
- الفروع (branches)
- الدمج (merges)
- التعارضات (conflicts)
- .gitignore
تعلّم أولًا
83 دقيقة قراءة · 3 ساعة تدريب (تقدير)
مخرجات التعلم
- Initialize a repository, stage changes, and write clear commit messages.
- Inspect history and differences with
log,status, anddiff. - Create, switch, and merge branches, and resolve a merge conflict by hand.
- Write a
.gitignorethat excludes build output and secrets.
الدروس
المختبر والتمارين
Lab
BEG-046-LAB1 · Version your work
Outcomes: 1–4 · Time: ~3 h Put the Bank Accounts project under Git with meaningful commits (at least five). Create a feature branch, make conflicting changes on both branches, merge, and resolve the conflict by hand. Add a .gitignore. Acceptance: clean history (clear messages, no target/ or .idea/); conflict resolved correctly.
Exercises (assessment: terminal-only Git task)
| ID | Outcome | Task |
|---|---|---|
| BEG-046-EX01 | 1 | In a new folder, initialize a repo, create Hello.java, stage and commit it with a clear message. |
| BEG-046-EX02 | 1 | Rewrite these bad messages as good ones: "fix", "stuff", "changes". Use a bug-fix example of your own. |
| BEG-046-EX03 | 2 | Change a file, then show the difference unstaged and staged. Which two commands did you use? |
| BEG-046-EX04 | 2 | List the last five commits in one-line form. |
| BEG-046-EX05 | 3 | Create branch greeting, commit a change, switch back, and merge with no conflict. |
| BEG-046-EX06 | 3 | Make both branches edit the same line, merge, and resolve the conflict. |
| BEG-046-EX07 | 4 | Write a .gitignore for a Java project; prove target/ stays untracked. |
أظهر الحلول
- EX01
git init,git add Hello.java,git commit -m "Add Hello program". - EX02 e.g. "Fix negative balance after withdraw", "Add Account class with deposit", "Rename amount to balance".
- EX03
git diff(unstaged) andgit diff --staged. - EX04
git log --oneline -5. - EX05
git switch -c greeting, commit,git switch main,git merge greeting(fast-forward). - EX06 After
git merge, open the file, keep the intended text, delete the markers,git add file,git commit. - EX07
target/,*.class,.idea/,.env;git statusdoes not list them.
الاختبار
Outcomes: O1 init, stage, commit · O2 inspect history · O3 branch and merge · O4 .gitignore.
اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.
الجزء العملي
Terminal-only Git task: init, commit, branch, conflict, merge, .gitignore (EX01–EX07 and the lab). Pass: at least 8 of 10 quiz questions and a clean history with the conflict resolved.
أخطاء شائعة
"fix" commit messages; committing target/ or .idea/; committing passwords.
التقييم
Terminal-only Git task.
الصلة بالمسار الوظيفي
Daily tool; team workflows in JNR-053.