> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# تكامل Git

> أنشئ رمز وصول، واستنسخ مشروعًا باستخدام Git، ثم نفّذ pull وpush.

اعمل على مشروع من جهاز الكمبيوتر الخاص بك باستخدام Git. لا تنتقل التغييرات إلا عند تشغيل `git pull` أو `git push`.

> [!NOTE]
>
> يجب على المسؤول تفعيل [تكامل Git](https://ayakaleaf-pro.mintlify.site/ar/on-premises/configuration/overleaf-toolkit/integrations/git-integration.md) أولًا.

## إنشاء رمز

يسجّل Git الدخول باستخدام رمز مصادقة Git، وليس بكلمة مرور حسابك.

**1. افتح إعدادات حسابك**

انقر على **Account**، ثم **Account settings**. ضمن **Git integration**، انقر على **Generate token**. بعد أن يصبح لديك رمز، يصبح اسم هذا الزر **Add another token**.

![قسم Git integration في إعدادات الحساب مع زر Generate token](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/git-integration-settings.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=f4ff1f16eb46266f7bf31956bf3b9d89)

تكامل Git في إعدادات الحساب

**2. انسخ الرمز**

انقر على **Copy** واحفظ الرمز في مكان آمن. لن تراه إلا مرة واحدة. ثم انقر على **Close**.

![مربع حوار رمز مصادقة Git مع زر Copy](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/git-integration-token.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=8358a37df6799da34fd12c6503f619f5)

رمزك الجديد

**3. تحقّق من الرمز**

تعرض القائمة الآن بداية الرمز، ووقت إنشائه، وآخر وقت استُخدم فيه. تنتهي صلاحيته بعد سنة واحدة. يمكنك امتلاك ما يصل إلى 10 رموز.

![قائمة الرموز وفيها رمز واحد](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/git-integration-tokens.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=e96fcc8b665f3005f950b7706fdf451c)

رموزك

## استنساخ مشروع

**1. افتح تكامل Git في المحرر**

افتح المشروع. في الشريط الأيسر، انقر على **Integrations**، ثم **Git integration**.

![لوحة Integrations مع بطاقة Git integration](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/git-integration-panel.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=3fb82c63ba8d205191eadb5015bdefb5)

لوحة Integrations

**2. انسخ الأمر**

يعرض مربع الحوار **Clone with Git** الأمر، مع عنوان موقعك ومعرّف المشروع. انقر على **Copy**. إذا لم يكن لديك رمز بعد، يفتح **Go to settings** إعدادات حسابك في علامة تبويب جديدة.

![مربع الحوار Clone with Git مع الأمر git clone](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/git-integration-clone.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=f6d69046df7caf4cbee07f49e8dd6540)

أمر الاستنساخ

**3. شغّله**

الصق الأمر في الطرفية. عندما يطلب Git كلمة مرور، الصق رمزك.

```text theme={null}
$ git clone https://git@<your-site>/git/<project-id>
Cloning into '<project-id>'...
Password for 'https://git@<your-site>': <your-token>
```

يحتوي الآن مجلد يحمل اسم معرّف المشروع على ملفات المشروع، على الفرع `main`. لاختيار اسم المجلد، أضفه في نهاية الأمر.

يطلب Git الرمز في كل مرة يتصل فيها بالموقع. لكي يتذكّره، فعّل credential helper: يطلبه Git مرة أخرى، ثم يحتفظ بالرمز. يحفظ الـ helper ‏`store` الرمز دون تشفير في `~/.git-credentials`.

```bash theme={null}
git config --global credential.helper store
```

## سحب التغييرات من المحرر

داخل المجلد، شغّل:

```bash theme={null}
git pull
```

يسرد Git الملفات التي تغيّرت. تصل التغييرات التي أُجريت في المحرر على شكل commits باسم `Update on Overleaf.`.

```text theme={null}
Updating db007e3..c3e6332
Fast-forward
 main.tex | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
```

## دفع تغييراتك

نفّذ commit لتغييراتك، ثم ادفعها:

```bash theme={null}
git add main.tex
git commit -m "Add a line from Git"
git push
```

يعرض السطر الأخير من المخرجات الفرع الذي تقدّم:

```text theme={null}
   53aca61..db007e3  main -> main
```

تظهر التغييرات في المحرر، ويتحدّث المحرر المفتوح من تلقاء نفسه. تظهر الملفات والمجلدات الجديدة وعمليات إعادة التسمية في شجرة الملفات. في **History**، يُوسَم تغييرك بـ **You (via Git)**. لا تظهر رسالة الـ commit هناك.

![سجل المشروع يعرض السطر المدفوع، موسومًا بـ You (via Git)](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/git-integration-history.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=e2f4d5575612ebd75db3656cac1ea495)

عملية push في سجل المشروع

### إذا رفض Git عملية الدفع

إذا تغيّر المشروع في هذه الأثناء، يرفض Git عملية الدفع:

```text theme={null}
 ! [rejected]        main -> main (fetch first)
```

اجلب تلك التغييرات أولًا، ثم ادفع مرة أخرى:

```bash theme={null}
git pull --no-rebase --no-edit
git push
```

قد يتوقف `git pull` العادي بالرسالة `fatal: Need to specify how to reconcile divergent branches.` يعالج الخيار `--no-rebase` أعلاه ذلك: فهو يدمج الجانبين.

إذا تغيّرت الأسطر نفسها في الجانبين، يتوقف pull بالرسالة `CONFLICT (content): Merge conflict in main.tex`. أصلح الملف، ثم شغّل:

```bash theme={null}
git add main.tex
git commit -m "Merge the changes from the editor"
git push
```

هناك أمران لا يقبلهما الموقع:

* الفروع الأخرى: `! [remote rejected] feature -> feature (wrong branch)`. لا يوجد سوى `main`، لذا ادفع عملك إليه.
* الدفع القسري: `! [remote rejected] main -> main (forced push prohibited)`. بدلًا من ذلك، ضع تغييراتك فوق `main` الحالي.

### إذا أظهر Git الرسالة Authentication failed

```text theme={null}
remote: Enter your Git authentication token when prompted for a password.
fatal: Authentication failed for 'https://<your-site>/git/<project-id>/'
```

الرمز خاطئ أو محذوف، أو أنك أدخلت كلمة مرور حسابك. أنشئ رمزًا جديدًا إذا لم يعد لديك، لأنه لا يمكنك عرض رمز موجود مرة أخرى.

## حذف رمز

في **Account settings**، ضمن **Git integration**، انقر على أيقونة الحذف بجوار الرمز، ثم **Delete** في مربع الحوار. منذ ذلك الحين، يرد Git على هذا الرمز بـ `Authentication failed`.

![مربع الحوار Delete Authentication token](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/git-integration-delete-token.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=1708062228778239c6465b0369614a18)

حذف رمز

> [!NOTE]
>
> لمعرفة ما يمكن للمتعاونين ذوي صلاحية القراءة فقط فعله، راجع قسم Q\&A في [تكامل Git](https://ayakaleaf-pro.mintlify.site/ar/on-premises/configuration/overleaf-toolkit/integrations/git-integration.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.