Gitlab
Create a free repository on GitLab
Address -
gitlab.com/sing_in
or
gitlab.com/users/sing_in
You need to sign up, confirm your email and create the first project.
SSH access to GitLab
Add the key gitlab.com
Go to your home directory and generate a key with ssh keygen
cd
ssh-keygen -t rsa -b 2048
The easiest name for the key is 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]-----+
Create the file config
touch ~/.ssh/config
vi ~/.ssh/config
# GitLab.com
Host gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitlab_com_rsa
Copy the key contents to the clipboard.
In
Windows
GitBash
cat ~/.ssh/gitlab_com_rsa.pub | clip
In Linux if you have xclip
xclip -sel clip < ~/.ssh/gitlab_com_rsa.pub
The copied key has to be pasted into the field Key in gitlab.com/~/profile/keys
User Settings > SSH Keys
Example
Now you can clone from GitLab over SSH
mkdir test
cd test
git init
touch .gitignore
git clone git@gitlab.com:YOUR_ACCOUNT/PROJECT_NAME.git
GitHub
Address -
github.com
A Free account means that you can work only with a public repository.
About working with a public
API
github read
here
Everyone can see your code, but only you can edit it.
Do not store files with passwords in a public repository. If you need privacy - buy the private mode (Private) or move to another service, for example BitBucket.org.
Once the account is created, click the plus sign and select New repository
Change the directory
$ cd /c/Users/aolegovich/Desktop/Sites
We have already covered how to clone a repository from GitHub here for example:
$ 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
Check which remote repository git links the local repository to
$ git remote -v
origin https://github.com/Name/name.git (fetch)
origin https://github.com/Name/name.git (push)
If you have not connected to github, gitlab or any other services yet, you can do it with the command
git remote add origin https://git.company.com/user/projectName.git
Of course, you first need to create a project on the website of the service + you need to run git init .
remote set-url
Change the linked remote repository
$ git remote set-url origin https://github.com/YourAccount/your project name.git
Check whether the linked repository has changed
$ git remote -v
origin https://github.com/YourAccount/your project name.git (fetch)
origin https://github.com/YourAccount/your project name.git (push)
push
Send new data to the remote repository
$ 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
If you need to push from another branch - just write its name instead of 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
Then you need to follow the link
https://gitlab.yourcompany.com/Project/Project/merge_requests/new?merge_request%5Bsource_branch%5D=some%2Fother%2Fbranch_name
and make a Merge Request
pull
If the remote repository has moved ahead and you want to update your local repository with the data from the remote one
$ git pull origin master
Article author: Andrei Olegovich