Основы Git: загрузка существующего локального проекта в git-проект
10 авг 2022 · 10:05
Наверняка каждый из нас был на определенном этапе, когда у вас есть локальная папка с быстрым проектом, а вскоре проект оказывается довольно полезным, и вы захотели установить на него контроль версий. Как же преобразовать эту папку в git-проекти даже отправить его на GitHub?
10.08.2022.01.png90.6 KB
Прежде всего, мы должны иметь этот локальный проект где-то на нашем компьютере, у нас это папка local-gitter, которая содержит очень простой сайт.
Структура локальной папки gitter
Создание проекта GitHub
Теперь давайте перейдем на GitHub и создадим новый пустой проект.
Новый проект GitHub
На следующем экране вы можете заполнить имя вашего проекта и добавить описание.
По желанию вы можете выбрать создание файла readme или gitignore.
Настройки нового репозитория GitHub
После того как мы создали репозиторий, важно отметить его URL.
GitHub repo url
Перенос существующих файлов в репозиторий
Теперь давайте откроем наш любимый терминал и выполним следующие шаги:
Перейдите в папку проекта.
git init (начать новый git-проект)
touch. gitignore (добавить игнорирование файла, добавить сюда файлы, которые вы не хотите видеть в git)
git add. или git add ${all relevant files} (точка добавляет все, иначе добавьте все файлы, которые вы хотите видеть в git)
git commit -m «первое сообщение» (Сделайте его хорошим сообщением)
git remote add origin git@github. com: rebelchris/local-gitter. git (измените на свой URL)
git push -u origin master
Примечание: Файл gitignore очень полезен, чтобы не проталкивать такие вещи, как, например, node_modules, всегда убедитесь, что они добавлены в gitignore.
И мы закончили! Теперь, если мы перейдем на GitHub, то увидим все файлы, которые мы только что загрузили.
GitHub со всеми нашими файлами
Заключение
Понравилась статья? Тогда Ставьте лайки, пишите комментарии, делитесь ею с друзьями, а также подписывайтесь на нас тут и на остальных платформах (ссылка в шапке профиля).
{"document": [{"text": [{"type": "string", "attributes": {}, "string": "Наверняка каждый из нас был на определенном этапе, когда у вас есть локальная папка с быстрым проектом, а вскоре проект оказывается довольно полезным, и вы захотели установить на него контроль версий. Как же преобразовать эту папку в "}, {"type": "string", "attributes": {"bold": true}, "string": "git"}, {"type": "string", "attributes": {}, "string": "-проект"}, {"type": "string", "attributes": {"bold": true}, "string": " "}, {"type": "string", "attributes": {}, "string": "и даже отправить его на GitHub?"}], "attributes": []}, {"text": [{"type": "attachment", "attributes": {"presentation": "gallery"}, "attachment": {"caption": "", "contentType": "image/png", "filename": "10.08.2022.01.png", "filesize": 92774, "height": 1080, "pic_id": 119497, "url": "https://storage.yandexcloud.net/pabliko.files/article_cloud_image/2022/08/08/10.08.2022.01.jpeg", "width": 1920}}], "attributes": []}, {"text": [{"type": "string", "attributes": {}, "string": "Прежде всего, мы должны иметь этот локальный проект где-то на нашем компьютере, у нас это папка "}, {"type": "string", "attributes": {"bold": true}, "string": "local-gitter"}, {"type": "string", "attributes": {}, "string": ", которая содержит очень простой сайт."}], "attributes": []}, {"text": [{"type": "attachment", "attributes": {"caption": "Структура локальной папки gitter", "presentation": "gallery"}, "attachment": {"caption": "", "contentType": "image/png", "filename": "10.08.2022.02.png", "filesize": 18989, "height": 194, "pic_id": 119498, "url": "https://storage.yandexcloud.net/pabliko.files/article_cloud_image/2022/08/08/10.08.2022.02.jpeg", "width": 333}}], "attributes": []}, {"text": [{"type": "string", "attributes": {}, "string": "Создание проекта GitHub"}], "attributes": ["heading1"]}, {"text": [{"type": "string", "attributes": {}, "string": "Теперь давайте перейдем на GitHub и создадим новый пустой проект."}], "attributes": []}, {"text": [{"type": "attachment", "attributes": {"caption": "Новый проект GitHub", "presentation": "gallery"}, "attachment": {"caption": "", "contentType": "image/png", "filename": "10.08.2022.03.png", "filesize": 22993, "height": 231, "pic_id": 119499, "url": "https://storage.yandexcloud.net/pabliko.files/article_cloud_image/2022/08/08/10.08.2022.03.jpeg", "width": 345}}], "attributes": []}, {"text": [{"type": "string", "attributes": {}, "string": "На следующем экране вы можете заполнить имя вашего проекта и добавить описание."}], "attributes": []}, {"text": [{"type": "string", "attributes": {}, "string": "По желанию вы можете выбрать создание файла readme или gitignore."}], "attributes": []}, {"text": [{"type": "attachment", "attributes": {"caption": "Настройки нового репозитория GitHub", "presentation": "gallery"}, "attachment": {"caption": "", "contentType": "image/png", "filename": "10.08.2022.04.png", "filesize": 118675, "height": 866, "pic_id": 119500, "url": "https://storage.yandexcloud.net/pabliko.files/article_cloud_image/2022/08/08/10.08.2022.04.jpeg", "width": 750}}], "attributes": []}, {"text": [{"type": "string", "attributes": {}, "string": "После того как мы создали репозиторий, важно отметить его URL."}], "attributes": []}, {"text": [{"type": "attachment", "attributes": {"caption": "GitHub repo url", "presentation": "gallery"}, "attachment": {"caption": "", "contentType": "image/png", "filename": "10.08.2022.05.png", "filesize": 33506, "height": 105, "pic_id": 119501, "url": "https://storage.yandexcloud.net/pabliko.files/article_cloud_image/2022/08/08/10.08.2022.05.jpeg", "width": 931}}], "attributes": []}, {"text": [{"type": "string", "attributes": {}, "string": "Перенос существующих файлов в репозиторий"}], "attributes": ["heading1"]}, {"text": [{"type": "string", "attributes": {}, "string": "Теперь давайте откроем наш любимый терминал и выполним следующие шаги:"}], "attributes": []}, {"text": [{"type": "string", "attributes": {}, "string": "Перейдите в папку проекта."}], "attributes": ["bulletList", "bullet"]}, {"text": [{"type": "string", "attributes": {"bold": true}, "string": "git init"}, {"type": "string", "attributes": {}, "string": " (начать новый git-проект)"}], "attributes": ["bulletList", "bullet"]}, {"text": [{"type": "string", "attributes": {"bold": true}, "string": "touch. gitignore"}, {"type": "string", "attributes": {}, "string": " (добавить игнорирование файла, добавить сюда файлы, которые вы не хотите видеть в "}, {"type": "string", "attributes": {"bold": true}, "string": "git"}, {"type": "string", "attributes": {}, "string": ")"}], "attributes": ["bulletList", "bullet"]}, {"text": [{"type": "string", "attributes": {"bold": true}, "string": "git add."}, {"type": "string", "attributes": {}, "string": " или "}, {"type": "string", "attributes": {"bold": true}, "string": "git add ${all relevant files}"}, {"type": "string", "attributes": {}, "string": " (точка добавляет все, иначе добавьте все файлы, которые вы хотите видеть в "}, {"type": "string", "attributes": {"bold": true}, "string": "git"}, {"type": "string", "attributes": {}, "string": ")"}], "attributes": ["bulletList", "bullet"]}, {"text": [{"type": "string", "attributes": {"bold": true}, "string": "git commit -m"}, {"type": "string", "attributes": {}, "string": " «первое сообщение» (Сделайте его хорошим сообщением)"}], "attributes": ["bulletList", "bullet"]}, {"text": [{"type": "string", "attributes": {"bold": true}, "string": "git remote add origin git@github. com: rebelchris/local-gitter. git"}, {"type": "string", "attributes": {}, "string": " (измените на свой URL)"}], "attributes": ["bulletList", "bullet"]}, {"text": [{"type": "string", "attributes": {"bold": true}, "string": "git push -u origin master"}], "attributes": ["bulletList", "bullet"]}, {"text": [{"type": "string", "attributes": {"italic": true}, "string": "Примечание: Файл "}, {"type": "string", "attributes": {"bold": true, "italic": true}, "string": "gitignore "}, {"type": "string", "attributes": {"italic": true}, "string": "очень полезен, чтобы не проталкивать такие вещи, как, например, "}, {"type": "string", "attributes": {"bold": true, "italic": true}, "string": "node_modules"}, {"type": "string", "attributes": {"italic": true}, "string": ", всегда убедитесь, что они добавлены в "}, {"type": "string", "attributes": {"bold": true, "italic": true}, "string": "gitignore"}, {"type": "string", "attributes": {"italic": true}, "string": "."}], "attributes": []}, {"text": [{"type": "string", "attributes": {}, "string": "И мы закончили! Теперь, если мы перейдем на GitHub, то увидим все файлы, которые мы только что загрузили."}], "attributes": []}, {"text": [{"type": "attachment", "attributes": {"caption": "GitHub со всеми нашими файлами", "presentation": "gallery"}, "attachment": {"caption": "", "contentType": "image/png", "filename": "10.08.2022.06.png", "filesize": 38270, "height": 238, "pic_id": 119506, "url": "https://storage.yandexcloud.net/pabliko.files/article_cloud_image/2022/08/08/10.08.2022.06.jpeg", "width": 920}}], "attributes": []}, {"text": [{"type": "string", "attributes": {}, "string": "Заключение"}], "attributes": ["heading1"]}, {"text": [{"type": "string", "attributes": {"bold": true}, "string": "Понравилась статья? Тогда Ставьте лайки, пишите комментарии, делитесь ею с друзьями, а также подписывайтесь на нас тут и на остальных платформах (ссылка в шапке профиля)."}], "attributes": []}], "selectedRange": [0, 0]}
Комментарии 1