Git works. Git

Home / Doesn't turn on

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. IN Debian system(which 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 with GitHub, you must first generate an 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 to the 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 operating system Linux first needs to look in 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 the operating room Windows system An 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 email as your mailbox. 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 describe the logic of actions on at the moment.

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

The tariff plan selection page will open. 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 click " in the upper right corner 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 the field Title You can write the name of the computer on which the public key was generated. You can write in Russian.

In the field Key you need to insert the contents of the file id_rsa.pub. Do you remember what directory they are in? We go to this directory, open the file id_rsa.pub with any text editor (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.

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 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 its 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 console version 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:
“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

Github is a very famous platform for storing, distributing and managing the source code of open source 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 post 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 a new account on the site, open home page GitHub and you can immediately enter the details for the 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 in right side panel button with a brush and click on it:

Will open text editor 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 window for viewing changes:

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 command line, see the article for beginners.

Git. A quick start to using basic operations with explanations

The file(s) are now firmly established in the HEAD of your working local copy. You can't kick them out of there, but they still aren't in your remote repository. Let's put them in there too! Use:

Git push origin master

Just instead of master, write the name of the desired branch. Oh yes, you don’t know what branches are yet. Okay, remember this place for now, and when you read about the branching, come back here.

Oh yes, for cool dudes who work with servers (it’s appropriate to talk about GitHub, for example), the command will be like this:

Git remote add origin [server]

Branching

In English this thing is called branching- it’s better to delve deeply into this issue and read about branching in more detail, I’ll just introduce you to it. Branching used for simultaneous and independent development of different features (well, or accumulation of more bugs, because source code gets bigger). The main branch is master- it appears when creating a repository. Other branches are sandboxes; when you have played enough of them, merge them into a single whole in master. Now I will explain how this is done.

Creating a new branch

So you decided to work on some new feature. Create a new branch for it:

Git checkout -b [new_branch]

Oh yes, your imagination is probably working to its fullest, but moderate it when it comes to naming branches: you can only name a branch with a name that is acceptable for a variable in your favorite language.

Switching between branches

Should I take a break from working on this feature and switch to another branch? Use (if you are working with a local repository, you do not need to specify its name):

Git checkout [repository]/[branch]

Well, if you don’t want to work with it at all, then delete it completely:

Git branch -d [branch]

You can do whatever you want with your branch: no one will see it until you push it to the remote repository with the command:

Git push origin [branch]

Merging branches

To merge a branch into the one you are currently working on, use:

Git merge [branch]

But, of course, this all leads to conflicts. And this is a real problem. So try to fix everything manually right in the repository directory. Just then don’t forget to mark that you “leaked” them:

Git add [filename]

By the way, the branches can be compared:

Git diff [one_branch] [other_branch]

So, now let's take more decisive action. We will update our repository in accordance with the latest commit. It's very easy to do (but it's not very easy to put it back, so think twice before making this terrible mistake):

Git pull

Of course, I understand that you are too cool to leave any notes for the future - keep everything in your head - but I still recommend that you leave tags. And this is not my invention, many people do this:

Git tag [first_ten_characters of the_corresponding_commit]

You don't know what the first characters are in the name of the desired commit? No problem, look at the history of the repository - its log:

There are a bunch of different parameters for using this useful thing, go ahead and Google them yourself. Oh yes, by the way, we already wrote about that once.

Damn it, I did the wrong thing!

Well, now let me tell you how to correct your mistakes, although you are sure that you will not make them. If the problem is only in one file, then here is Ctrl+Z for HEAD:

Git checkout -- [filename]

But if the problem is already in the local repository, then clear everything there and return the version from the server:

Git fetch origin git reset --hard origin/master

Yes, dude, everything is hard here. This is git.

Git features

If you are lazy, and you don’t want to write everything in the shell of your OS, then you can use git’s GUI:

You will find a bunch of other GUIs.
If you find git's standard output boring, color it up:

Git config color.ui true

Well, there is also such a thing - interactive indexing. When you already have a fairly large project, you can compress the index representation in the log like this:

Git add -i

I hope this guide will help you in the early stages not to get confused in working with git and you will finally learn to monitor your backups.

GitHub - what is it? This resource is a web-based version control and collaboration platform for software developers. Delivered through a software-as-a-service business model, it was launched in 2008. The resource is based on Git, a source code management system designed to speed up software development.

GitHub is currently the most popular code hosting service among developers and programmers.

GitHub - what is it?

Git is used to store a project's source code and keep track of a complete history of all code changes. This allows developers to collaborate more effectively on a project by providing tools to manage possible conflicting changes from multiple developers. Working with GitHub allows you to adapt and improve software from its public repositories for free, but charges for private repositories, offering a variety of tariff plans. Each public or private repository contains all project files, as well as the modification history of each file. Repositories can have multiple employees and can be either public or private.

How to work on GitHub?

The platform facilitates social coding by providing a web interface for a Git code repository and management tools for collaboration. This project can be considered as a serious social networking resource for software creators.

How Participants can code together, evaluate each other's work, receive updates on specific projects, and communicate publicly or privately.

Users can add other participants to their project for collaboration.

Terminology

Three important terms used by developers in the GitHub.com environment are fork, pull request, and merge.

A fork is a repository that has been copied from one member's account to account another. This tool allows the developer to make changes without affecting the source code.

Because GitHub is intuitive and easy to use, and its version control tools are useful for collaboration, the resource has become popular among specialists of various fields, including non-programmers. In particular, they began to use it for working on documents and multimedia developments. For example, documentation projects, learning resources, and other types of work in which users can interact online and work together. GitLab is an open source alternative to GitHub.com.

Products and Features

In addition to the famous GitHub.com product, the SaaS founder offers an on-premises version. GitHub Enterprise supports integrated development environments, integrated tooling, and many third party applications and services. The resource offers increased security and the possibility of verification.

Other products and app features include:


© 2024 ermake.ru -- About PC repair - Information portal