#5 — Введение в GitHub. Работа с удаленным репозиторием

<< #4 – Работа с ветками. Объединение веток

https://itproger.com/course/git/5

Заходим на github.com, нажимаем «New»:

Создаем новый репозиторий

Создаем новый репозиторий:

Публичный, так как приватные — платные (около 7$ в месяц).

git remote add origin — подключение к удаленному репозиторию

Мы попадаем на страницу репозитория:

Здесь github подсказывает нам команды. Но, так как некоторые команды мы уже исполнили, выполним команду для подключения к удаленному репозиторию:

git remote add origin https://github.com/diman3210/github-tutorial.git

Проверим подключение:

G:\OpenServer\domains\gittest.loc>git remote
origin

«origin» — значит, что мы подключены к удаленному репозиторию «origin».

git push — выгрузка файлов в удаленный репозиторий

Для выгрузки файлов воспользуемся командой:

G:\OpenServer\domains\gittest.loc>git push -u origin master

Это означает, что мы выгружаем файлы в репозиторий под названием «origin» в ветку «master».

GitHub попросит нас авторизоваться:

Вводим свой логин-пароль от учетной записи github и авторизоваемся.

GitHub в это время скачает файлы на свой сервер:

Enumerating objects: 73, done.
Counting objects: 100% (73/73), done.
Delta compression using up to 12 threads
Compressing objects: 100% (55/55), done.
Writing objects: 100% (73/73), 8.65 KiB | 590.00 KiB/s, done.
Total 73 (delta 17), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (17/17), done.
To https://github.com/diman3210/github-tutorial.git
 * [new branch]      master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

Обновим страницу с нашим репозиторием в Гитхаб и увидим, что все наши файлы туда уже скачались.

Добавление файла README.md

Добавим файл README.md в нашем редакторе и напишем в него:

#Тестирование GitHub
Это проект для тестирования Гит и ГитХаб

Этот файл поддерживает разметку markdown .

Добавим в локальный репозиторий:

G:\OpenServer\domains\gittest.loc>git add .

Сделаем коммит:

G:\OpenServer\domains\gittest.loc>git commit -m "add readme.md"
[master ecbb2f7] add readme.md
 1 file changed, 2 insertions(+)
 create mode 100644 README.md

и закинем измененные-добавленные файлы в репозиторий:

G:\OpenServer\domains\gittest.loc>git push -u origin master
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 382 bytes | 382.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/diman3210/github-tutorial.git
   8a7b121..ecbb2f7  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

git clone — клонирование репозитория

Создадим новый проект gittest2.loc и выполним клонирование в наш проект:

G:\OpenServer\domains\gittest2.loc>git clone https://github.com/diman3210/github-tutorial
Cloning into 'github-tutorial'...
remote: Enumerating objects: 79, done.
remote: Counting objects: 100% (79/79), done.
remote: Compressing objects: 100% (43/43), done.
remote: Total 79 (delta 18), reused 79 (delta 18), pack-reused 0
Unpacking objects: 100% (79/79), 9.28 KiB | 59.00 KiB/s, done.

Мы клонировали проект https://github.com/diman3210/github-tutorial в нашу папку.

Перейдем в папку github-tutorial и выполним:

G:\OpenServer\domains\gittest2.loc>cd github-tutorial

G:\OpenServer\domains\gittest2.loc\github-tutorial>git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

Как видите инициализацию проходить не надо, все и так работает.

git pull — скачивание новых и измененных файлов с репозитория

В проекте gittest2.loc внесем изменение в файл и создадим новый файл.

И зальем все это на наш репозиторий в github:

G:\OpenServer\domains\gittest2.loc\github-tutorial>git add .

G:\OpenServer\domains\gittest2.loc\github-tutorial>git commit -m "New files"
[master 7a96399] New files
 2 files changed, 11 insertions(+)
 create mode 100644 www/index2.html

G:\OpenServer\domains\gittest2.loc\github-tutorial>git push -u origin master
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 12 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 493 bytes | 493.00 KiB/s, done.
Total 5 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), completed with 2 local objects.
To https://github.com/diman3210/github-tutorial
   640fdfd..7a96399  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

Теперь в проекте gittest.loc скопируем все это к себе:

G:\OpenServer\domains\gittest.loc>git pull
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 5 (delta 3), reused 5 (delta 3), pack-reused 0
Unpacking objects: 100% (5/5), 473 bytes | 43.00 KiB/s, done.
From https://github.com/diman3210/github-tutorial
   640fdfd..7a96399  master     -> origin/master
Updating 640fdfd..7a96399
Fast-forward
 www/index.html  |  1 +
 www/index2.html | 10 ++++++++++
 2 files changed, 11 insertions(+)
 create mode 100644 www/index2.html

В результате у нас появился новый файл, и обновился измененный.

<< #4 – Работа с ветками. Объединение веток

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Межтекстовые Отзывы
Посмотреть все комментарии