📜 ⬆️ ⬇️

How to start working with GitHub: quick start



Distributed version control systems (DVCS) are gradually replacing centralized ones. If you are not using one of them yet - it's time to try.

In this article, I will try to show how you can quickly start experimenting with git using github.com.
')
The article will not discuss the differences between different DVCS. Also, work with git will not be considered in detail, there are many good sources on this topic, which I will cite at the end of the article.

So, the site github.com is positioned as a web service for hosting projects using the git version control system, as well as a social network for developers. Users can create an unlimited number of repositories, each of which is provided with a wiki, issue tracking system, it is possible to carry out code review and much more. GitHub is currently the most popular service of its kind, ahead of Sourceforge and Google Code.

For open-souce projects using the site for free. If you need to have private repositories, it is possible to switch to a paid tariff plan:


Let's start with registration. Follow the link github.com/signup/free and enter your data.
After registration, we get to our account Dashboard:


Now we don’t have a single repository, and we can either create a new repository, or fork from an existing foreign repository and maintain our own development branch. Then, if you wish, you can suggest your changes to the author of the source repository (Pull request).

But first, install git and configure it to work with the site.

If you are working in Windows, download and install msysgit . This is a console version of git for Windows (hereinafter the story will be conducted using the example of this OS).
MacOS X Instructions (eng)
Linux instructions (eng)
There should be no problems, just click Next everywhere. After installation, select in the context menu of Git Bash Explorer:


or via Git Bash.lnk in the folder with the installed program:


We register in the console our data and settings for line breaks:
git config --global user.name " "
git config --global user.email " "
git config --global core.autocrlf true
git config --global core.safecrlf true


By the way, I recommend to take a good online course on using git from the console. The course takes several hours and gives the necessary basic skills.

For those who prefer gui - for Windows there are several such tools for working with git. The two main ones are SmartGit (cross-platform) and TortoiseGit . Both are not bad, and what to use is a matter of taste. I will describe working with TortoiseGit.
For poppies, the choice of giu is also available.


Download link code.google.com/p/tortoisegit/downloads/list . When installing everywhere click Next.

Now go back to github and create a new repository. While on the Dashboard, click New Repository (https://github.com/repositories/new), enter the data and click Create Repository.

GitHub allows you to work with repositories in three ways: SSH, HTTP and Git Read-Only, respectively, providing three types of links for our repository:
1. git@github.com:habrauser/Hello-world.git
2. habrauser@github.com/habrauser/Hello-world.git
3. git://github.com/habrauser/Hello-world.git



In order to simply pick up the repository on a local machine, the internal git protocol is sufficient (the third link). This is the fastest and most efficient way to provide anonymous read-only access.

If we want to make changes to the repository on github, we need to use HTTP or SSH.
Work on http does not cause any difficulties, at the right time, just use the account password on github.

To use SSH, we need to create a special key pair: public and private. The public one will be placed in the account settings on github, and the private one will be saved on the local machine.

To generate keys, you can use the ssh-keygen tool that comes with git (you can read the description of this method here ). We will use PuTTY (or rather a small program puttygen, included in its composition). PuTTY is such a client for remote access, including using SSH.

Downloading the latest version from the official site (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html). By the way, the older version puttygen (2007) comes as part of TortoiseGit.

After installing PuTTY, run puttygen from the folder with the installed program:


Click Generate, move the mouse cursor for a while to get random data required by the algorithm.


Enter the password that protects our private key in the Key passphrase field, enter the confirmation, click the Save private key, save.

Next, copy the public key in the OpenSSH format from the “Public key for pasting ...” text area and go to our account settings on github (Account Settings) in the SSH Public Keys section:


click Add another public Key, insert our public key:


click Add key. Everything, now we are ready to work with github on ssh. Let's try to pick up our empty rezitoriyor on a local machine using TortioseGit. In the context menu of the explorer choose Git Clone ...


Insert the SSH address of our repository into the Url field, specify the path to our private key in the Load Putty Key field, click OK.


Pageant will ask us for the password for the private key (then this will not be required)


Pageant is an SSH authentication agent in PuTTY that allows you to manage private keys.
His icon is hanging in the tray:


The repository successfully cloned to the local machine.


Now we will try to change the local repository and send the changes to github. Add the README file to the local repository (the file with the name README is processed by github in a special way - its contents will be displayed as a description of the repository on the corresponding page)


Let's commit changes to the local repository.




and sync it with the repository on github:


push push


Now going to the page of our repository, we will see the following:


For each repository, the site offers a wiki:


as well as a simple issue tracking-a system:


By the way, for those who use Eclipse in their work, there is a corresponding mylyn-connector for github:


and EGit plugin:


The Explore GitHub link opens a directory of repositories in which you can search by many other criteria, including programming languages, popularity, etc.


In summary, I would like to say that if you are a novice developer who plans to start using version control systems, or is more experienced and has a look at distributed VCS, but does not know how to start, then it makes sense to try git using such a great tool like github.com.

useful links


To work with git:
code.google.com/p/msysgit git for windows
www.syntevo.com/smartgit/index.html SmartGit
code.google.com/p/tortoisegit TortoiseGit
http://www.chiark.greenend.org.uk/~sgtatham/putty/ PuTTY

About git in Russian:
habrahabr.ru/blogs/Git/106912 "Successful branching model for git" - translation of a good English-language article
githowto.com online git course from console
habrahabr.ru/blogs/Git/106912 "Why git" + discussion
habrahabr.ru/blogs/development/68341 "Git for moving with SVN" + discussion
habrahabr.ru/blogs/Git/75990 "Team work in git" + discussion
progit.org/book/ru Russian translation of the book "Pro Git" (not fully translated)
habrahabr.ru/blogs/Git/123111 instruction-cheat sheet for beginners
los-t.livejournal.com/tag/git%20guts a cycle of posts "git guts "
lib.custis.ru/%D0%9B%D0%B8%D0%BD%D1%83%D1%81_%D0%A2%D0%BE%D1%80%D0%B2%D0%B0%D0%BB % D1% 8C% D0% B4% D1% 81_% D0% BE_GIT_% D0% BD% D0% B0_Google_Talks Linus Torvalds about git
habrahabr.ru/blogs/Git/80909 book "The magic of git"

About git in English:
books

video
other

Source: https://habr.com/ru/post/125799/


All Articles