Gitlab

Contents
Создать бесплатный репозиторий на GitLab
Доступ к GitLab по ssh
Удалённое хранение на GitHub
remote -v: Проверить с каким удалённым репозиторием git связывает локальный репозиторий
remote set-url: Изменить привязанный удалённый репозиторий
push: Отправить новые данные на удалённый репозиторий
pull: Загрузить данные из удалённого репозитория и обновить ими локальный
Другие статьи про Git

Создать бесплатный репозиторий на GitLab

Адрес - gitlab.com/sing_in или gitlab.com/users/sing_in

Нужно зарегистрироваться, подтвердить почту и создать первый проект.

Доступ к GitLab по ssh

Добавить ключ gitlab.com

Перейдите в домашнюю директорию и сгенерируйте ключ с помощью ssh keygen

cd
ssh-keygen -t rsa -b 2048

Ключ проще всего назвать gitlab_com_rsa

Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/Andrei/.ssh/id_rsa): gitlab_com_rsa Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in gitlab_com_rsa Your public key has been saved in gitlab_com_rsa.pub The key fingerprint is: SHA256:wAhrNr63vvUrQvhP6dbekTHlk6wtP7Y+fIJWnpLyCQN Andrei@DESKTOP-OP43ER5 The key&339;s randomart image is: +---[RSA 2048]----+ | . . | | 2 = + . | |E * = = | | . + . B . | | ... =+ S | | .. .. =. | | .o..*=+ | | ..=J=*+o. | | +PP=+*= | +----[SHA256]-----+

Создайте файл config

touch ~/.ssh/config
vi ~/.ssh/config

# GitLab.com Host gitlab.com PreferredAuthentications publickey IdentityFile ~/.ssh/gitlab_com_rsa

Копируем содержимое ключа в буфер.

В Windows GitBash

cat ~/.ssh/gitlab_com_rsa.pub | clip

В Linux если стоит xclip

xclip -sel clip < ~/.ssh/gitlab_com_rsa.pub

Скопированный ключ нужно вставить в поле Key в gitlab.com/~/profile/keys

User Settings > SSH Keys

GitLab сохранить свой ssh ключ изображение с сайта www.aredel.com
GitLab.com
Пример

Теперь можно клонировать из GitLab по SSH

mkdir test
cd test
git init
touch .gitignore
git clone git@gitlab.com:ВАШ_АККАУНТ/ИМЯ_ПРОЕКТА.git

GitHub

Адрес - github.com

Бесплатный (Free) аккаунт означает, что Вы можете работать только с публичным (Public) репозиторием.

О работе с публичным API github читайте здесь

Все могут видеть Ваш код, но редактировать его можете только Вы.

Не храните в публичном репозитории файлы с паролями. Если Вам нужна приватность - покупайте приватный режим (Private) или переходите на другой сервис, например BitBucket.org.

После того как аккаунт создан нажмите на плюсик и выберите New repository

Создать новый профиль на github изображение с сайта www.aredel.com

Изменить директорию

$ cd /c/Users/aolegovich/Desktop/Sites

Как клонировать репозиторий с GitHub уже разбирали здесь например:

$ git clone https://github.com/Name/name.git

Cloning into 'heihei.ru'...

remote: Enumerating objects: 83, done.
remote: Total 83 (delta 0), reused 0 (delta 0), pack-reused 83
Unpacking objects: 100% (83/83), done.

remote -v

Проверить с каким удалённым репозиторием git связывает локальный репозиторий

$ git remote -v

origin https://github.com/Name/name.git (fetch)
origin https://github.com/Name/name.git (push)

Если Вы ещё не подключились ни к github ни к gitlab ни к другим сервисам, сделать это можно командой

git remote add origin https://git.company.com/user/projectName.git

Конечно, предварительно нужно создать проект на сайте сервиса + нужно заранее сделать git init .

remote set-url

Изменить привязанный удалённый репозиторий

$ git remote set-url origin https://github.com/YourAccount/your project name.git

Проверить изменился ли привязанный репозиторий

$ git remote -v

origin https://github.com/YourAccount/your project name.git (fetch)
origin https://github.com/YourAccount/your project name.git (push)

Banner Image

push

Отправить новые данные на удалённый репозиторий

$ git push origin master

Enumerating objects: 83, done.
Counting objects: 100% (83/83), done.
Delta compression using up to 4 threads
Compressing objects: 100% (81/81), done.
Writing objects: 100% (83/83), 3.36 MiB | 3.19 MiB/s, done.
Total 83 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), done.
To https://github.com/andreiolegovichru/travel-site.git
* [new branch] master -> master

Если нужно делать push из другой ветки - просто напишите её называние вместо master

git push origin some/other/branch_name

Enumerating objects: 30, done. Counting objects: 100% (30/30), done. Delta compression using up to 8 threads Compressing objects: 100% (26/26), done. Writing objects: 100% (26/26), 6.32 KiB | 6.32 MiB/s, done. Total 26 (delta 7), reused 0 (delta 0) remote: remote: To create a merge request for some/other/branch_name, visit: remote: https://gitlab.yourcompany.com/Project/Project/merge_requests/new?merge_request%5Bsource_branch%5D=some%2Fother%2Fbranch_name remote: To gitlab.ssh.com:IAM/IAM.git abcdefdc8..abcdef000 topic/qa/init_perf_test_controller -> topic/qa/init_perf_test_controller

Затем нужно перейти по ссылке

https://gitlab.yourcompany.com/Project/Project/merge_requests/new?merge_request%5Bsource_branch%5D=some%2Fother%2Fbranch_name

и сделать Merge Request

pull

Если удалённый репозиторий ушёл вперед и вы хотите обновить свой локальный репозиторий данными с удалённого

$ git pull origin master

Banner Image
Related Articles
Git remote
Git
GitHub
Migrate from HTTPS auth to SSH
GitLab
Banner Image

Search on this site

Subscribe to @aofeed channel for updates

Visit Channel

@aofeed

Feedbak and Questions in Telegram

@aofeedchat