البرمجة

إنشاء فرع محلي يتبع فرعًا بعيدًا غير موجود في Git

Yes, it is possible to simultaneously create a local branch that tracks a currently non-existing remote branch and switch to it. However, the command you tried (git checkout --track origin/my_branch_name) is not correct for this purpose.

To achieve this, you can use the following command:

bash
git checkout -b my_branch_name origin/my_branch_name

This command will create a new local branch (my_branch_name) that tracks the remote branch (origin/my_branch_name) and switches to it all at once.

المزيد من المعلومات

عند استخدام الأمر git checkout -b my_branch_name origin/my_branch_name، يتم إنشاء فرع محلي جديد باسم my_branch_name ويتم تعقب الفرع البعيد origin/my_branch_name والانتقال إليه في نفس الوقت. يعني هذا أن أي تغييرات تقوم بها في الفرع المحلي ستكون متابعة تلقائيًا في الفرع البعيد عندما تقوم بدفع التغييرات.

إذا كان الفرع البعيد origin/my_branch_name غير موجود بعد على الخادم البعيد، فإن استخدام هذا الأمر سيقوم بإنشاء الفرع المحلي وربطه بالفرع البعيد المستقبلي المحتمل.

زر الذهاب إلى الأعلى