حذف الفروع التي ليست في المستودع المحلي باستخدام git

StackOverflow https://stackoverflow.com/questions/3536315

سؤال

هناك مجموعة من الفروع على أحد ريبو Git الخاص بي الذي حصلت عليه عندما كنت متشعبًا على Github. لا أريد أن يكون لشوكة جيثب هذه الفروع.

هل هناك أي طريقة يمكنني من خلالها حذف جميع الفروع على repo github التي ليست في ريبو المحلي الخاص بي؟

هل كانت مفيدة؟

المحلول

git push --mirror <origin> سيجعل الحكام على المباراة عن بُعد في المستودع المحلي ، بما في ذلك حذف الفروع التي لا تملكها محليًا.

من git help push:

--mirror
    Instead of naming each ref to push, specifies that all refs under
    refs/ (which includes but is not limited to refs/heads/,
    refs/remotes/, and refs/tags/) be mirrored to the remote
    repository. Newly created local refs will be pushed to the remote
    end, locally updated refs will be force updated on the remote end,
    and deleted refs will be removed from the remote end. This is the
    default if the configuration option remote.<remote>.mirror is set.

نصائح أخرى

يمكنك حذف الفروع عن بُعد دفع فرع فارغ:

$ git push origin :branch-to-delete
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top