How to get started with GitHub: quick start. Git

Github is a very famous platform for storing, distributing and managing source code open projects. This service is used by many developers around the world, including large companies such as Microsoft, RedHat and many others, as well as hundreds of developers of many popular projects.

The platform provides opportunities not only for viewing code and its distribution, but also version history, collaborative development tools, tools for providing documentation, issuing releases and feedback. And the best part is that you can host both public and private projects on Gihub. In this article we will look at how to use Github to host your project. So to speak, github for beginners.

So let's say you have your own project and you want to host its code on Github in open access so that other users can view it and participate in the development. The first thing you need to do is create an account.

1. Account creation

To create new account open on the website home page GitHub and immediately you can enter data for a new account. You need to provide a username, email and password:

When you are finished entering, press the button "Sign Up Free":

In the next step, you need to select the repository type. Public repositories are free, but if you want to create a private repository, the code from which will be available only to you, you will have to pay $7 per month.

Your account is ready and you will be redirected to a page where you can create your first project. But before you can do this, you need to confirm your Email address. To do this, open your Mailbox and follow the link in the email from Github.

No github setup is needed, just a few clicks are enough.

2. Creating a repository

On the page that opens, this is the main page for authorized users, click the button "Start a project":

You can immediately initialize the repository by creating a Readme file by checking the box "Initialize this repository with a README" at the bottom of the page. You can also select a license:

When ready, select "Create project", a new project will be created with a README file containing a description and a license file.


3. Adding branches

Github branches allow you to work with multiple versions of a project at the same time. By default, when creating a repository, the master branch is created, this is the main working branch. You can create additional branches, for example, in order to test software before it is published to the master branch. This way, you can simultaneously develop the product and provide a stable version to users. You can also create separate branches for the program version for different systems.

The current branch is indicated in the upper left corner after the word "Branch". To create a new branch, simply expand this list and start typing its name:

The site itself will prompt you to create a new thread, select "Create branch".

Immediately after creation, you will be working with the newly created branch.

4. File changes and commits

Any changes to files on Github are made using commits. A commit is accomplished by making the fixes themselves and describing those fixes. This is necessary so that you know what and when you changed, and also makes it easy to track the team's work. The word commit can be translated as “fix”. That is, we can make changes to several files and then commit them. Let's change the README file as an example. To do this, find the button with a brush on the right side of the panel and click on it:

A text editor will open where you can enter the corrections you need:

After you have done everything you need, you need to fill out the field "Commit" at the bottom of the page. Briefly describe what has changed, and then click the button "Commit changes":

These changes will be made to the current branch of the project, since we are currently working with testing, the changes will be sent there.

5. Creating Pull Requests

GitHub for beginners may seem very complicated precisely because of such features, but it is very convenient once you figure it out. A Merge Request or Pull Request is a feature whereby any developer can ask another, such as the creator of a repository, to review their code and add it to the main project or branch. The Merge Request tool uses the diff comparison tool, so you can see all the changes, they will be underlined in a different color. Pull Request can be created immediately after creating a commit. Let's send a Pull Request from our testing branch to the main branch. First open the tab "Pull Request".

Click here "Create Pull Request":

In this window you can view all changes; now we see that the line has been added:

6. Review and approve merge requests

Now, on the same Pull Requests tab we see the newly created merge request and all we have to do is accept it by clicking "Merge Pull Request":

But if this request came from another person, you must check what he changed there and whether it is necessary. To do this, just click on the request description and you will see the already familiar change view window:

The code will then be imported into the master branch and the testing branch can be safely deleted.

7. Bug reports

Another convenient thing is that you can use GitHub not only for developing and managing code, but also for feedback from users. On the tab "Issue" Users can post messages about problems they encountered while using your product. Open the tab "Issues", and click on the button "New issue":

8. Releases

The last thing we'll look at today is releases. When the product has reached a certain stage, you can release a release so that users and you can be sure that everything is stable there and no one broke anything with an incorrect Pull Request in the Master. First you need to go to the main page of the project, then to the tab "Releases":

On this page you need to specify the version in the field "Tag Version", then the release name and a short description. If you have compiled archives with binaries, then you also need to attach them here. Then click "Create Release":

After creating the release, the following page will be created:

conclusions

In this article, we looked at how to use GitHub to host and manage your project. The entire system is in English, so basic knowledge of the language is very desirable, but even without it, working with github will not be very difficult. I hope this information was useful to you. If you are interested in how to work with Git from the command line, see the article for beginners.

Distributed version control systems (DVCS) are gradually replacing centralized ones. If you haven't used one of them yet, now is the time to try.

In this article I will try to show how you can quickly start experimenting with git using the github.com website.

This article will not discuss the differences between different DVCS. Also, working with git will not be considered in detail; there are many on this topic good sources which I will provide at the end of the article.

So, the site github.com is positioned as a web project hosting service using the git version control system, as well as social network for developers. Users can create an unlimited number of repositories, each of which is provided with a wiki, an issue tracking system, the ability to conduct code reviews and much more. GitHub on this moment is the most popular service of its kind, surpassing Sourceforge and Google Code.

For open-souce projects, use of the site is free. If you need to have private repositories, you can upgrade to a paid plan:

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

Now we don’t have a single repository, and we can either create a new repository, or fork from an existing someone else’s repository and lead our own development branch. Then, if desired, you can propose your changes to the author of the original repository (Pull request).

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

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

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

We enter our data and line break settings in the console:
git config --global user.name "your name"
git config --global user.email "your email"
git config --global core.autocrlf true
git config --global core.safecrlf true

By the way, I recommend taking a good interactive course on using git from the console. The course is completed in a few hours and provides the necessary basic skills.

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

  • The official client from GitHub is still quite crude in my opinion.
  • GitX - I personally didn’t like it
  • GitBox - most follows the mac-way, I highly recommend trying it

About git in Russian:
habrahabr.ru/blogs/Git/106912 “A successful branching model for git” - translation of a good English article
githowto.com interactive course on working with git from the console
habrahabr.ru/blogs/Git/106912 “Why git” + discussion
habrahabr.ru/blogs/development/68341 “Git for those migrating from SVN” + discussion

This describes the practical part of using Git - installing it and registering it on the GitHub.com server.

GitHub.com is a service that offers storage of your code and data using a version control system Git. GitHub provides a free plan for storing 300MB of plaintext data. This means that any Internet user can download your data. You can also host repositories that are closed to others on GitHub by paying $7 per month. On a free GitHub account, by default, no one can change your data (they can only read it). But you can dictate which users of the GitHub system have write rights.

The article explains in detail how to configure Git on Windows OS and Linux OS.

Installing Git on Linux

I think there is no point in explaining to Linux users how to install Git - this is done differently on each system. On a Debian system (which is what I have), to install Git, you can use the command:

apt-get install git

Installing Git on Windows

Let's go to official page Git http://git-scm.com, click on Download for Windows . In the window that opens, click on Full installer for official Git. We launch the resulting exe file.

During the installation process you will be asked the following question:

I recommend choosing "Run Git from the Windows Command Prompt". All other options can be left as default. After installing Git, you must reboot or log out and log back in for the changes to the system PATH variable to take effect.

If we get version information, then Git is installed and working. If we receive information that the git program was not found, we figure out what we did wrong.

Setting up SSH keys

Before registering on GitHub, you must first generate SSH encryption key. This key is required to quickly establish a connection to GitHub without entering a password. Without such a key, GitHub simply will not work.

Attention!

When the key is generated, you will be asked for a password. This is the access password private key, which is stored only on your machine and nowhere else. This password is set for maximum security, although you can do without it. You need to know that having set a password for the private key, you will need to enter each time you connect to the GitHub server given password. Thus, when setting a password, all the convenience of using encryption keys disappears.

MyTetra users: The command line interface that is used to call git during synchronization cannot accept character input. Therefore, if you set a password, synchronization will not work.

Setting up SSH keys on Linux

In the operating room Linux system First you need to look into the ~/.ssh directory. If there are files id_rsa and id_rsa.pub, then these are SSH keys. If there is no such directory or such files, then the keys need to be generated. We give the command:

Instead of [email protected] you need to indicate your email. During the key generation process you will be asked where to put the files; in response, simply press Enter. When prompted for a password, simply press Enter. After generation, the files id_rsa and id_rsa.pub should appear in the ~/.ssh directory; they will be useful to us in the future.

Setting up SSH keys on Windows

IN operating system Windows SSH key generator is included with Git. To generate keys, you need to run the file C:\Program Files\Git\Git bash.vbs. It can be launched as a regular exe file. The Git Console program will open. In it you need to give the command:

ssh-keygen -t rsa -C " [email protected]"

Be careful, copy-paste is buggy in this console, it’s easier to enter the command manually. We indicate your mailbox as your email. Upon request " Enter file in which to save the key" simply press Enter. When prompted for a password, " Enter passphrase " and " Enter same passphrase again " simply press Enter. During the process of generating keys, approximately the following information will be displayed in the console:

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Documents and Settings/username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Documents and Settings/username/.ssh/id_rsa.
Your public key has been saved in /c/Documents and Settings/username/.ssh/id_rsa.pub.
The key fingerprint is:
51:db:73:e9:31:9f:51:a6:7a:c5:3d:da:9c:35:8f:95 [email protected]

After executing this program, in the directory C:\Documents and Settings\username\.ssh There will be files id_rsa and id_rsa.pub, they will be useful to us in the future.

Register on GitHub.com

Now everything is ready for registration. Let's go to home page GitHub.com. The interface is a little confusing, so I’ll give you a couple of screenshots of where to click what. The design and layout can be changed at any time, so I am describing the logic of actions at the moment.

In the top menu we find the item " Pricing and Signup" and click on it:

The selection page will open tariff plan. Select a free account" Create a free account":

Installing an SSH key on GitHub

Immediately after registration, you must register your public encryption key (public SSH key) in the GutHub system. To add a key, you need to go to the right top corner press " Account Settings":

In the window that opens, click on the menu item " SSH Public Keys", and press " Add Another Public Key". Two fields will appear - the name of the key ( Title) and the contents of the key ( Key).

In field Title You can write the name of the computer on which the public key was generated. You can write in Russian.

In field Key you need to insert the contents of the file id_rsa.pub. Do you remember what directory they are in? Go to this directory, open with any text editor file id_rsa.pub (exactly with the extension .pub, do not confuse it). Select all the text, copy, and paste it into the field on the GitHub page Key.

After adding the key, the computer can connect to GitHub through the git program and no errors should occur.

Creating a repository on GitHub

Now it's time to create your first GitHub repository. The repository can be considered simply as a directory in which the synchronized files and subdirectories will be located. You need to create a repository in the GitHub web interface, and you can fill it with files and work with it using the git program on your computer.

To create a repository, you need to click " in the upper right corner Dashboard". In the window that opens you will see the item " Create A Repository":

So, we don’t need this point! This item does not open the repository creation dialog, but a help page. Instead of clicking on this item, look for an inconspicuous link below on the page " Create A Repository". It will open the dialog for adding a new repository.

In the dialog for adding a new repository, you need to fill in at least the project name field " Project Name". It is better not to use the Cyrillic alphabet in the project name, since the project name is in fact the name of the directory. To avoid problems, it is better that the project name contains only the Latin alphabet. After clicking the " Create Repository", the repository will be created.

A working link to the repository in the GitHub system is formed as follows. If you are registered as username and your repository is called reponame , then you can use the following links to access this repository:

In Git syntax:

[email protected]:username/reponame.git

In Https syntax:

https:// [email protected]/username/reponame.git

Working with a repository on GitHub using the Git program

From this moment on, the dance around the GitHub web interface can be considered complete. Further you can work only using the git program.

First you need to make a small configuration of the git program: specify local system git username and email. This is done with the following commands, which can be executed from any directory:

git config --global user.name "YourFullName"
git config --global user.email [email protected]

where instead of YourFullName you need to write your name, and instead of [email protected]- your email. These values ​​are used for GitHub login. Therefore, in place of YourFullName you need to indicate your login on GitHub, and in place [email protected] you need to specify the email that you entered when generating encryption keys.

After these settings, you can upload your files to the repository. Go to the directory with your project and give the commands:

git commit -a -m "first commit"

git remote add origin [email protected]:username/reponame.git

git push -u origin master

After these commands, copies of the files in the directory in which these commands were executed are created on the GitHub server. Then you can make commits, upload changes to the GitHub server, and read changes from the server. But that's a completely different story.

If you have decided to take your first steps towards using VCS (Version Control System), then you should already understand how useful this thing is. There are a lot of advantages to using such systems, but that’s not what this article is about. In this article I will tell you how to start working (under Windows 7) with one of the most popular systems version control - Github.

Very often in free speech we say not github, but simply git, meaning the resource https://github.com, however, these are not exactly the same things. The GitHub resource itself is a web shell of a system for monitoring and managing our projects. This is a kind of social network for developers and not only for PHP, but also for other programming languages. As for Git itself, this is the program that we will install on our computer/laptop.

In order to get started, we will need to download two programs:

  1. msysgit. Download latest version you can from here -> Git
  2. TortoiseGit (32bit and 64bit)

After you have downloaded these two programs, let's begin installing them.

Note! First we need to put msysgit, and then - TortoiseGit

The msysgit installation process is intuitive, so we won’t dwell on it. The only thing is that all the settings that are offered to us during the installation process can be left unchanged and left as default.

Indicate the item that you see on the screen above.

After installing these packages, consider the first stage completed. The second stage is gaining access to our Github repository.

First, we need to register on the website https://github.com. Registration on this site is simple and not much different from similar operations on other sites.

Note! When registering, please indicate the real email you use.

After this, we will need the email address that we provided during registration. If you suddenly forgot which one you specified during registration, you can view it in the Edit Profile -> Emails section (https://github.com/settings/emails) and you will see it in the main window:

We're done here, now we need to generate an SSH key. This is a digital signature for your computer. To get this key, we need the same git. After installing it, a Git Bush shortcut should appear on your desktop. Double clicking on it will launch the console.

Note! If you do not have this shortcut on your desktop, then this command line can be called like this: on the desktop, on free space call the context menu with the mouse and in the list of items you will find the same Git Bush

Now in command line you need to run the command:

ssh-keygen -t rsa -C "E-Mail from your profile"

After this, the message “Enter file in which to save the key” will appear here. For now we will leave everything as it is and just press Enter. Now we are asked to enter a password, for now we will skip this step by pressing Enter, but later this password can be entered independently. After this, we will generate two files - one of them will be our SSH key.

Note! You may not have the ssh-keygen module installed and the above command simply will not work, and as a result, the key will not be generated. In this case, either download programs like putty. More details in the article on Habr -> http://habrahabr.ru/. Or use an HTTPS connection.

If you did everything as described in these instructions and did not change anything in the process, then the files will be located here: C:/users/(UserName)/.ssh/

In this folder we will need a file ida_rsa.pub, which you need to open using a regular notepad and copy the contents to the clipboard (simply put, in open file press Ctrl+A, then Ctrl+C).

The next setup step is to add this key to your Github profile. To do this, go to your profile settings: Settings -> SSH Keys and click the Add SSH key button, as shown in the screenshot below.

A form with two fields has opened in front of you:

  1. Title

Leave the title empty, but in the Key field paste the text you copied earlier from the file ida_rsa.pub.

Congratulations, another stage is over. Just a little more and you will be able to enjoy working in your own repository.

Now create a separate folder on the local host in which your project will be stored and call the context menu on it. Then select TortoiseGit -> Settings as shown in the screenshot:

In the window that opens on the left, you will see a tree menu. You need to select Git -> Config and write down your name and email address exactly the same as you indicated when registering on Github.

Now we need to clone (copy) the repository to our computer. To do this, go to your created repository on Github and on the right you will see its address:

Copy this address to your clipboard. Now call the context menu on the folder that you created for your project and select the command " Git Clone...":

A window has opened where we need to paste the copied address of our repository:

Pay attention to the Directory field - sometimes another folder may be added. Make sure that the path there is to your project folder, and not some other one. Now click OK. Cloning begins:

Continuation of the article about working with Git. Learning to add files, commit and push >

Distributed version control systems (DVCS) are gradually replacing centralized ones. If you haven't used one of them yet, now is the time to try.

In this article I will try to show how you can quickly start experimenting with git using the github.com website.

This article will not discuss the differences between different DVCS. Also, working with git will not be discussed in detail; there are many good sources on this topic, which I will provide at the end of the article.

So, the site github.com is positioned as a web project hosting service 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, an issue tracking system, the ability to conduct code reviews and much more. GitHub is currently the most popular service of this kind, ahead of Sourceforge and Google Code.

For open-souce projects, use of the site is free. If you need to have private repositories, you can upgrade to a paid plan:

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

Now we don’t have a single repository, and we can either create a new repository, or fork from an existing someone else’s repository and lead our own development branch. Then, if desired, you can propose your changes to the author of the original repository (Pull request).

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

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

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

We enter our data and line break settings in the console:
git config --global user.name "your name"
git config --global user.email "your email"
git config --global core.autocrlf true
git config --global core.safecrlf true

By the way, I recommend taking a good interactive course on using git from the console. The course is completed in a few hours and provides the necessary basic skills.

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

  • The official client from GitHub is still quite crude in my opinion.
  • GitX - I personally didn’t like it
  • GitBox - most follows the mac-way, I highly recommend trying it

About git in Russian:
“A successful branching model for git” - translation of a good English article
githowto.com interactive course on working with git from the console
“Why git” + discussion
“Git for those migrating from SVN” + discussion

Internet