GIT - basic concepts, motivation

GIT - motivation , principles

  • Keeping a history of any changes made to information or data. We are able to go back to any point in the history and retrieve the correct state of the source code. Git does not store data as a series of changes or differences, but as a series of snapshots.
  • Branching / merging is used when a developer starts working on new functionality. But in general, it allows to separate the development of a new feature and discard the changes if necessary (cancel the whole branch).
  • Teamwork - is already mentioned in the general concepts of versioning. Unlike CVS and SVN, there is no file locking, developers can work on one at a time and GIT will then try to merge their changes. Most current Cloud services allow setting rights over each of the repositories, setting up a process that for each change another colleague's revision is still required or it cannot be merged into the whole, etc. Usually some sort of task and error manager is included, so there is no need for more complex tools on smaller projects, and it is fully sufficient for small teams (or even communities).
  • Decentralization - if I need to, I don't have to download repositories from a server or from the cloud, I can connect to a colleague's IP address and send my changes there. When the central node goes down, all repositories on developers' PCs are full and no history is lost.
  • Connectivity - generally all issue and bug management tools (Jira, Redmine, etc.) and CI tools (Jenkins, TeamCity) allow advanced connectivity to GIT. That is, if we name each change and each branch correctly, JIRA can correctly pair them with requirements and preview the change directly within itself.

Basic property of GIT

  • Fast
  • Secure
  • Simple branching
  • Simple merging

Overview of basic concepts

  • Repository – a repository is a logical grouping of documents (files) or even directories that are part of a larger whole (for example, the source code of a program. In SVN, for example, the repository is always only on the server and each developer has only the current version + changes in progress. With distributed versioning systems, everyone has a full repository (including complete history) and any repository can claim to be the main repository. The main one is usually hosted on a server or cloud.
  • Branch - the "splitting" of a developmental pathway into two or more branches, with the new branch still linked to the original developmental lineage. In most cases, there is a main development branch, the content of which is usually deployed in production. From this, e.g. sprint branches are then made in agile development, and the developer makes his own branch for each feature being developer.
  • term Origin means the designation of a branch on a remote repository
  • Merge – merging of branches, which takes place, for example, when several people are working on one file at the same time. It is done by evaluating the differences in the merged files and then generating the resulting file, which is built from two or more input files. For example, removing or adding a line of text and modifying a line of text is taken as a change. As a rule, however, the modification of whitespace characters (logical indentation, indentation from the beginning of a line) is ignored, as this does not change the meaning of the text (code) (the exception is programming languages such as Python, where indentation is used to enclose blocks of code). If there are multiple changes close together, the whole block is marked as changed. Sometimes the differences cannot be resolved by machine (changes were made to both files in the same block of code) and user intervention is required.
  • Commit – (delta is used in SVN) - is a kind of compact package that contains changes over several files. It is recommended to keep the changes in the commit as small as possible and mainly related. This will avoid unnecessary problems with merging and will also make the git log clearer. Each commit can be named. For SVN, commits (deltas) have an integer as ID, which increases by 1 with each additional delta. For GIT, the commit ID is in a long hash format (160 bits, where the change and file information is hashed, i.e. each hash should be unique).
  • Pull request – Developer creates 3 commits (one for FE changes, one for backend changes and one for DB changes) to develop a new feature. If he doesn't have the right to push these changes directly to the repository on the server, he creates a Pull request from these commits and sends it for approval. So most GIT solutions (e.g. Github, gitlab) have some defined process and permissions and only after approval (e.g. by the team leader) will this go to the server and others will see these changes. (We won't use this in our examples, it's a matter of larger projects).
  • .gitignore – this is a specific file that when in the repository, determines which files, directories will be ignored.

Where the GIT can run?

  • Locally or on a server in our network
  • Docker
  • Cloud
    • GitHub
    • Gitlab
    • Bitbucket

GitHub is a web service that supports software development using the Git versioning tool. GitHub offers free web hosting for open source projects. As of January 7, 2019, private repositories can also be hosted for free (previously, by paying a monthly fee). Launched in 2008, the project currently hosts over 11 million projects. It provides social networking features for users - notifications of changes, code discussions, suggestions for changes or submitting your own solutions (pull-requests).
The project was written using Ruby on Rails and Erlang.
GitHub provides additional services. For example, Gist, which is part of GitHub, allows versioning and quick sharing of shorter code. It also lets you host small project websites (e.g. try - which is the website of an editor developed by the GITHub community).

GitLab is a web-based Git repository with a wiki and bug tracking support. GitLab hosts accounts similar to GitHub, but also allows their software to be used on a third-party server. It is available as an Omnibus package and is written in Ruby. In many cases, it is installed on servers on companies' internal networks and used for internal projects.

Bitbucket is a web service supporting software development using Git and Mercurial versioning tools. Bitbucket offers free hosting for open-source projects and small teams of up to 5 people. It also offers commercial programs that allow you to host private repositories after paying a monthly fee. The project was written in Python and the Django framework. Until 2015, Bitbucket was called Stash. We use Bitbucket for internal GIT repositories at Tesena. Furthermore, it is e.g. deployed on the internal network of the savings bank and all IT projects store their source code there. Bitbucket is from Atlassian, it has better cooperation with Jira.

Complete and Continue