Sign In
Sign In

Installing and Using GitLab Runner

Installing and Using GitLab Runner
Hostman Team
Technical writer
Git GitLab CI/CD
27.05.2024
Reading time: 5 min

GitLab Runner is a web application (agent) designed to launch and automatically run CI/CD processes in GitLab. GitLab Runner runs tasks from the .gitlab-ci.yml file, which is located in the root directory of your project.

Runner can be installed either on the same server with GitLab or separately. The main thing is that there is network communication between GitLab Runner and the GitLab server. You can install Gitlab Runner on operating systems such as Linux, Windows, macOS, and it also supports running in a Docker container.

In this article, we will install GitLab Runner in Docker and run a test project.

Prerequisites

To install GitLab Runner, you will need:

  • A cloud server or a virtual machine running a Linux OS. You can use any Linux distribution compatible with Docker.

  • Docker installed. 

  • An account on gitlab.com, as well as a pre-prepared project.

You can install Docker manually (we have a step-by-step guide for Ubuntu) or automatically from Marketplace, when creating a new Hostman server.

Image1

Installing GitLab Runner using Docker

First, connect to the server where Docker is installed.

Create a Docker volume in which we will store the configuration.

A Docker volume is a file system for persistent storage of information. Data in a volume is stored separately from the container. The volume and the data will remain if you restart, stop, or delete the container. 

The command to create a volume named runner1 is:

docker volume create runner1

Next, launch the container with the gitlab-runner image:

docker run -d --name gitlab-runner1 --restart always \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v runner1:/etc/gitlab-runner\
    gitlab/gitlab-runner:latest

Check the status of the container and make sure that it is running (Up):

docker ps

Image10

This completes the installation of GitLab Runner. The next step is Runner registration.

Registering GitLab Runner

Once Runner has been installed, it must be registered. Without registration, Runner will not be able to complete tasks.

  1. Launch the gitlab-runner container and execute the register command:
docker run --rm -it -v runner1:/etc/gitlab-runner gitlab/gitlab-runner:latest register
  1. You will be prompted to enter the URL of the GitLab server:

Image14

If you are using self hosted GitLab installed on a separate server, use the address of your GitLab instance. For example, if your project is located at https://gitlab.test1.com/projects/testproject, then the URL will be https://gitlab.test1.com.

If your projects are stored on GitLab.com, then the URL is https://gitlab.com.

  1. Next, you will need to enter the registration token.

To get the token, go to the GitLab web interface, select the project, select the Settings section on the left, then CI/CD:

Image4

Find the Runners menu, expand the section. You will find the token in the Action menu (three dots):

Image9

  1. Next, you'll be prompted to enter a description for this Runner. You can skip it not writing anything:

Image3

  1. Now you need to set the tags. Tags are labels designed to determine which runner will be used when running tasks. You can enter one or several tags separating them by commas:

Image11

  1. When entering a maintenance note, you can add information for other developers, containing, for example, technical information about the server. You can also skip this step. 

Image2

  1. Select an executor, i.e. the environment for launching the pipeline. We will choose docker. In this case, the pipeline will be launched in Docker containers, and upon completion, the containers will be deleted.

Image5

  1. At the last step, select the Docker image to use in the container where the pipeline will be launched. As an example, let's choose the python 3.10-slim image:

Image17

After you are done registering the Runner, it will be displayed in the project settings, in the Runners section:

Image7

Using GitLab Runner when starting a pipeline

In order to use Runner to run a pipeline, you need to create a file called .gitlab-ci.yml. You can create a file directly in the root directory of the project or in the GitLab web interface:

  1. On the project main page click Set up CI/CD (this button is only visible before you set up CI/CD for the first time):

Image1 (1)

  1. Click Configure pipeline:

Image8

When you first set up a pipeline, GitLab provides the basic pipeline syntax. In our example, we use a Python project, namely a script to test the speed of an Internet connection. If the script executes successfully, the output should display information about incoming and outgoing connections:

Your Download speed is 95.8 Mbit/s
Your Upload speed is 110.1 Mbit/s

The pipeline syntax will look like this:

image: python:3.10-slim
default:
   tags:
     - test1
before_script:
     - pip3 install -r requirements.txt
run:
   script:
     - python3 check_internet_speed.py

To assign a previously created Runner to this project, you need to add:

default:
  tags:
    - test1

Where test1 is the tag of the Runner we created. With this tag, the pipeline will be executed on the Runner that is assigned the test1 tag. Save the changes to the file (make a commit) and launch the pipeline. If you look at the job execution process, you can see at the very beginning of the output that the gitlab runner is used:

Image13

The full output of the entire pipeline is shown in the screenshot below:

Image15

Conclusion

In this tutorial, we have installed and configured GitLab Runner, assigned it to a project, and launched the pipeline.

Git GitLab CI/CD
27.05.2024
Reading time: 5 min

Similar

Git

Git Rebase: How It Works and Why You Should Use It

In the Git version control system, there are two ways to combine one branch with another, represented by different commands: git merge. Commits from one branch are transferred into another by creating a merge commit. git rebase. Commits from one branch are transferred into another branch while preserving the original order of changes. Simply put: with git merge, the commits from one branch are “squashed” into one, while with git rebase they remain untouched, yet the branches are combined. Thus, the git rebase command allows you to combine commits from both branches by forming a shared history of changes. This guide will cover the git rebase command, which is responsible for rebasing commits (changes) from one branch to another. All the examples shown used Git version 2.34.1, running on a Hostman server with the Ubuntu 22.04 operating system. You can use these guides to install Git on your machine: Installing Git on Ubuntu Installing Git on Windows Understanding Git Rebase The best way to understand how rebasing works in Git is to look at an abstract repository consisting of several branches. At the same time, the rebasing operation should be considered step by step. Creating Branches Let’s assume we created a repository with a single branch master, containing just one commit. The master branch looks like this: master   commit_1 Then, based on master, we created a new branch hypothesis, where we decided to test some features. In this new branch, we made several commits improving the code. The branch now looks like this: hypothesis   commit_4   commit_3   commit_2   commit_1 Later, we added another commit to the master branch, urgently fixing a vulnerability. The master branch now looks like this: master   commit_5   commit_1 Now our repository has two branches: master   commit_5   commit_1 hypothesis   commit_4   commit_3   commit_2   commit_1 The master branch is the main branch, while hypothesis is secondary (derived). Later commits are listed above earlier ones, similar to the output of the git log command. Merging Branches Let’s say we want to continue working on the feature we had previously moved into the separate hypothesis branch. However, this branch does not contain the critical vulnerability fix we made in master. Therefore, we want to “synchronize” the state of hypothesis with master so that the fix commit also appears in the feature branch. In other words, we want the repository structure to look like this: master   commit_5   commit_1 hypothesis   commit_4   commit_3   commit_2   commit_5   commit_1 As you can see, the hypothesis branch now exactly repeats the history of master, even though it was originally created before commit_5. In other words, hypothesis now contains the history of both branches—its own and master. To achieve this, we need to rebase using the git rebase command. Afterward, the changes made in hypothesis can be merged into master using the classic git merge command, which creates a merge commit. Then the repository structure will look like this: master   commit_merge   commit_5   commit_1 hypothesis   commit_4   commit_3   commit_2   commit_5   commit_1 Moreover, running git merge after git rebase can reduce the likelihood of conflicts. Practice: git rebase Now that we’ve covered the theoretical aspect of the git rebase command, we can move on to testing it in a real repository of an improvised project. The repository structure will repeat the earlier theoretical example. Creating a Repository First, let’s create a separate directory to hold the repository: mkdir rebase Then move into it: cd rebase Now we can initialize the repository: git init In the console, a standard informational message should appear: hint: Using 'master' as the name for the initial branch. This default branch name hint: is subject to change. To configure the initial branch name to use in all hint: of your new repositories, which will suppress this warning, call: ... And in the current directory, a hidden .git folder will appear, which you can view with the following command: ls -a The -a flag means all and allows viewing the file system in extended mode. Its contents will be: .  ..  .git Before making commits, we need to specify some basic user information. First, the name: git config --global user.name "NAME" Then the email: git config --global user.email "NAME@HOST.COM" Populating the master Branch Using simple text files, we will simulate adding different functions to the project. Each new function will be represented as a separate commit. Create a file for the first improvised function: nano function_1 Fill it with the content: Function 1 Now index the changes made in the repository: git add . Just in case, check the indexing status: git status In the console, the following message should appear, showing the indexed changes: On branch master No commits yet Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: function_1 Now we can commit: git commit -m "commit_1" The console should display a message confirming the successful commit into master: [master (root-commit) 4eb7cc3] commit_1  1 file changed, 1 insertion(+)  create mode 100644 function_1 Populating the hypothesis Branch Now let’s create a new branch called hypothesis: git checkout -b hypothesis The -b flag is necessary to switch immediately to the new branch. The console will display a confirmation message: Switched to a new branch 'hypothesis' Next, we need to make three commits in sequence with three files, similar to master: commit_2 with file function_2 and content: Function 2 commit_3 with file function_3 and content: Function 3 commit_4 with file function_4 and content: Function 4 If we then check the commit list: git log --oneline The console will display the following sequence: d3efb82 (HEAD -> hypothesis) commit_4 c9f57b7 commit_3 c977f16 commit_2 4eb7cc3 (master) commit_1 Here, the --oneline flag is used to display commit information in a compressed single-line format. Adding a Commit to the master Branch The last step is to add another commit to the main branch master. Let’s switch to it: git checkout master The console will confirm the switch: Switched to branch 'master' Now create another improvised function file: nano function_5 With the following content: Function 5 Next, index the changes: git add . And make the new commit: git commit -m "commit_5" If we check the current commit list: git log --oneline The master branch will now have two commits: 3df7a00 (HEAD -> master) commit_5 4eb7cc3 commit_1 Merging Branches with git rebase To perform rebasing, first you need to switch to the hypothesis branch: git checkout hypothesis And run the rebase: git rebase master After this, the console will display a message confirming a successful rebase: Successfully rebased and updated refs/heads/hypothesis. Now you can check the commit list: git log --oneline The console will show a list containing the commits of both branches in the original order: 8ecfd58 (HEAD -> hypothesis) commit_4 f715aba commit_3 ee47470 commit_2 3df7a00 (master) commit_5 4eb7cc3 commit_1 Now the hypothesis branch contains the complete history of the entire repository. Resolving Conflicts Just like with git merge, when using the git rebase command, conflicts may occur that require manual resolution. Let’s modify our repository in such a way that we artificially create a rebase conflict. Create another file in the hypothesis branch: nano conflict And write the following text into it: There must be a conflict here! Index the changes: git add . And make another commit: git commit -m "conflict_1" Now switch to the master branch: git checkout master Create a similar file: nano conflict And fill it with the following content: There must NOT be a conflict here! Again, index the changes: git add . And make a commit: git commit -m "conflict_2" Reopen the created file: nano conflict And change its content to: There definitely must NOT be a conflict here! Again, index the changes: git add . And make another commit: git commit -m "conflict_3" Now switch back to the hypothesis branch: git checkout hypothesis And perform another rebase: git rebase master The console will display a conflict message: Auto-merging conflict CONFLICT (add/add): Merge conflict in conflict error: could not apply 6003ed7... conflict_1 hint: Resolve all conflicts manually, mark them as resolved with hint: "git add/rm <conflicted_files>", then run "git rebase --continue". hint: You can instead skip this commit: run "git rebase --skip". hint: To abort and get back to the state before "git rebase", run "git rebase --abort". Could not apply 6003ed7... conflict_1 Git suggests editing the conflict file, indexing the changes with git add, and then continuing the rebase using the --continue flag. That’s exactly what we will do: nano conflict The file will contain two conflicting versions wrapped in special markers: <<<<<<< HEAD There definitely must NOT be a conflict here! ======= There must be a conflict here! >>>>>>> 6003ed7 (conflict_1) Our task is to remove the unnecessary parts and fill the file with a final version of arbitrary text: There must absolutely definitely unanimously NOT be any conflict here! Now index the changes: git add . And continue the rebase: git rebase --continue After this, the console will open a text editor suggesting you modify the original commit message of the commit where the conflict occurred: conflict_1 # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # interactive rebase in progress; onto bd7aefc # Last commands done (4 commands done): # pick 8ecfd58 commit_4 # pick 6003ed7 conflict_1 # No commands remaining. # You are currently rebasing branch 'hypothesis' on 'bd7aefc'. # # Changes to be committed: # modified: conflict # The console will then display a message about the successful completion of the rebase process: [detached HEAD 482db49] conflict_1  1 file changed, 1 insertion(+), 1 deletion(-) Successfully rebased and updated refs/heads/hypothesis. Now if you check the commit list in the hypothesis branch: git log --oneline You will see the original sequence of all changes made: 482db49 (HEAD -> hypothesis) conflict_1 bd5d036 commit_4 407e245 commit_3 948b41c commit_2 bd7aefc (master) conflict_3 d98648d conflict_2 3df7a00 commit_5 4eb7cc3 commit_1 Notice that the commits conflict_2 and conflict_3, made in the master branch, appear in the history earlier than the conflict_1 commit. However, this applies to any commits made in the master branch. Rebasing a Remote Repository In addition to working with local branches, rebasing can be done when pulling changes from a remote repository. To do this, you need to add the --rebase flag to the standard pull command: git pull --rebase remote branch Where: remote is the remote repository branch is the remote branch Essentially, this pull configuration is equivalent to git rebase, except that the changes (commits) applied to the current branch are taken from the remote repository. Advantages of git rebase Linearity  The git rebase command makes it possible to form a fairly linear history of the target branch, consisting of sequentially made commits. Such a sequence without branching makes the history easier to perceive and understand. Fewer conflicts  Running git rebase beforehand can significantly reduce the likelihood of conflicts when merging branches with git merge. Conflicts are easier to resolve in sequential commits rather than in commits merged into a single merge commit. This is especially relevant when pushing branches to remote repositories. Disadvantages of git rebase History modification  Unlike merging, rebasing partially rewrites the history of the target branch, removing unnecessary history elements. Risk of errors  The ability to significantly restructure commit history can lead to irreversible errors in the repository. This means that some data may be permanently lost. Conclusion Merging two branches using rebasing, implemented with the git rebase command, is fundamentally different from the classic merge done with the git merge command. git merge turns the commits of one branch into a single commit in another. git rebase moves commits from one branch to the end of another while preserving the original order. A similar rebasing effect can also be achieved when using the git pull command with the additional --rebase flag. On one hand, the git rebase command allows you to achieve a cleaner and more understandable commit history in the main branch, which increases the maintainability of the repository. On the other hand, git rebase reduces the level of detail in changes within the branch, simplifying the history and removing some of its records. For this reason, rebasing is a feature intended for more experienced users who understand how Git works. Most often, the git rebase command is used together with the git merge command, allowing you to achieve the most optimal repository and branch structure.
16 September 2025 · 11 min to read
Microservices

Sending and Applying Git Patches via Email – No GitHub Needed

Git today is the most widespread and popular version control system. Probably 99% of all current projects use Git, from the Linux Kernel to simple JavaScript libraries consisting of just one file and one function. The Linux Kernel is a huge and very complex project. It involves a large number of programmers worldwide. Coordinating changes in this project would be simply impossible without an effective solution that allows this entire community to work independently of one another. Now, this seems like a simple and obvious solution. However, the path to it was long and thorny. A Brief Retrospective 1998 was an important year for Linux. Large vendors took notice of the project, and more and more developers joined. At that time, the project followed a fairly simple model for changes: developers would send their patches to Linus Torvalds, who decided whether to include the code or not. Torvalds liked this model because it gave him control over all changes. The patch mechanism was used back when code trees were small and computers were very large. A patch literally was a set of instructions on punch cards telling what and how to replace in a stack of these media to get a new program version. Punch tapes were literally cut into pieces and glued together in a specific way to introduce changes to the program code of that time.   In general terms, a set of patches is a set of instructions that allow editing (semi- or fully automatically) the source program to get a new version. A patch set is always smaller than the full code version. This turned patches into a convenient interface for transferring changes and collaborative programming. Problems arose when the developer community began to grow. Linus Torvalds became a "bottleneck"; the number of patches grew, and the time to review them increased. Developers began using the CVS version control system to ease collaboration. Of course, this went against Torvalds' original policy on Linux kernel changes. He disliked the existence of parallel project branches with their own workflow. On the other hand, developers felt frustrated sending patches to Torvalds, who physically could not review, accept, request fixes, or reject them in a timely manner. Developers complained they had to send multiple emails to get the "benevolent dictator's" attention. And if you’re looking for a reliable, high-performance, and budget-friendly solution for your workflows, Hostman has you covered with Linux VPS Hosting options, including Debian VPS, Ubuntu VPS, and VPS CentOS. The Emergence of Git The solution was to use a decentralized proprietary version control system called BitKeeper. The project used this software for a long time, but eventually, relations between the company developing BitKeeper and the Linux kernel developers soured. There was an amusing paradox: Linux Kernel is an open and free product licensed under the GNU General Public License (GPL). The main GPL principle is that anyone can freely use, distribute, and modify software released under this license, but all modifications must also be released under GPL. BitKeeper, however, was a fully closed proprietary commercial product owned entirely by its company.   Thus, the open and free project used a closed, non-free technology for coordinating development and versioning. Sooner or later, this fragile balance was going to break—and it did. This made using BitKeeper impossible. Torvalds rejected using Subversion and proposed Monotone instead. However, Monotone was unbearably slow. Eventually, Torvalds began writing his own version control system from scratch in C. Thus, Git was born. The new VCS was far from perfect but was positively received by the developer community and quickly gained the necessary tools. The new version control system rapidly gained popularity, and GitHub turned Git into the dominant solution for source code management in both open and commercial projects. Dominant... Indeed, any project, whether small or large (with thousands of contributors), is likely to be registered and hosted on GitHub. Even projects that don't use Git internally (like FreeBSD or OpenBSD) have read-only copies on GitHub. GitHub or Not GitHub? New developers (and not only them) tend to believe that without GitHub, project development and management are impossible. So, when you join a project as a developer (freelancer or FOSS contributor), you’ll be added to the team on this platform. Even if there are only two, three, or four of you... Even if the project consists of just a few dozen source files. GitHub everywhere. Is this good? It’s hard to answer simply yes or no. Certainly, GitHub has many useful tools; it’s convenient, fast, and reliable. Developers feel comfortable there, like in well-worn jeans. However, one should not forget that it’s a paid service managed by the well-known corporation Microsoft. Like any commercial product, GitHub is primarily focused on profit. If, for some reason, your project starts to interfere with that (damaging the platform’s image, etc.), your access will be instantly cut off. Recall the disputes GitHub had with the YouTube Downloader team, whose repositories were blocked, closed, and deleted simply because the RIAA demanded that GitHub restrict access to allegedly copyright-infringing software. This caused some (not a small number) teams to leave GitHub and switch to alternatives like GitLab or Gitea. In summary, setting aside moral and legal aspects, we see a contradiction: Git was designed as a decentralized version control system (unlike Subversion, for example), yet GitHub, which uses Git, enforces centralized management. Moreover, the developer effectively owns nothing; everything belongs to the "managing company." Is there life outside comfort? Can you use this great VCS without a third-party service? Can you accept patches without GitHub and send them to your team for review? Despite GitHub’s strong influence, Git’s architecture remains almost unchanged—it’s still a decentralized version control system. Git imposes absolutely no requirements on the exchange environment. You can use ordinary files (transfer them any way you want, even by copying to external media), upload patches to an FTP server, use SSH, or even Git’s built-in exchange protocol. This is very convenient. Recall the start of this article: Linus Torvalds accepted patches without GitHub (which didn’t exist then) by email and posted results on FTP servers. Sending Patches by Email Now, let's get to the main topic. Suppose we are a small, brave team that wants to be independent from anyone or anything. We have some money to buy a domain, VPS, and corporate email to exchange information and, of course, send and receive patches by email. Let's list tasks to build the necessary infrastructure for our project: Buy a domain. Buy corporate email and link it to our domain. Create mailboxes. Is it mandatory to buy a domain and corporate email? Not at all! You can use free mailboxes without a domain or purchase a domain later when needed. Everything depends on project requirements. However, from the early stages, the project may need a website, messaging (email), file exchange, and deployment infrastructure. You can buy these separately or combine them under one account for your project.  Suppose we are developing a web app and need infrastructure. After buying a domain and setting up DNS, we register as many mailboxes as needed. After creating mailboxes, we must configure access to them in mail clients and Git. Setting Up Git to Send and Receive Patches via Email It all starts with installing a special Git extension package called git-email. This is done using the package manager of your operating system or its distribution. For example: Fedora: sudo dnf install git-email Ubuntu / Debian: sudo apt-get install git-email On Windows, git-email is included in the standard Git installation package. Next step is configuration. In your OS terminal, run: git config --global --edit This will open your favorite terminal (or other) text editor, where you need to add the following lines to your Git configuration (the example uses test credentials; you should use your own!): [user] name = Maria Ortega email = zerozero@hostman-example.com [sendemail] smtpserver = smtp.hostman.com smtpuser = zerozero@hostman.site smtpencryption = ssl smtpserverport = 465 The parameter smtpencryption can be set to either ssl or tls. The second mode uses STARTTLS to initiate communication over an encrypted channel, while the first mode encrypts the connection immediately after it is established. The choice of mode and port depends on your email provider’s requirements. The [user] section is mandatory. Here, you identify yourself, and this information will appear in all patches and commits made by you. For stricter identification of patches and commits, Git supports signing sent information with GPG keys—but that’s another story. Now that we’ve set up Git to send patches via email let’s try it out. First, we need to clone a copy of the current working repository version. There are various ways to do this, which we’ll discuss at the end of the article. After cloning, make some changes to your project. Create a file named log_stderr.go: package main import ( "fmt" "time" "os" ) func logStderr(message string, args ...interface{}) { x := time.Now() fmt.Fprint(os.Stderr, x.Format(time.RFC822)) fmt.Fprint(os.Stderr, " - ") fmt.Fprintf(os.Stderr, message, args...) } Stage and commit the changes: git add log_stderr.go git commit -m "log into stderr func" Now send your patch to the project lead for review: git send-email --to="project-boss@hostman-example.com" HEAD^ The --to argument can accept multiple addresses separated by commas. This way, you can send your patch to all project members. You can also use --cc (carbon copy) to send the patch to additional email addresses separated by commas. This is useful when you want to send patches for review to the entire team or specific interested parties. To avoid specifying recipients every time on the command line, you can add them to your Git config: git config sendemail.to "project-boss@hostman-example.com" git config sendemail.cc "user1@email.tld","user2@email.tld",…,"userN@email.tld" After that, just run: git send-email HEAD^ …And your patch will be sent to the configured addresses. In this example, we sent the current changes from our working copy (HEAD^). You can send any changes, for example, two commits before the current one, or by commit hash. More details are in the Git documentation. Git will generate the patch and try to send it via the SMTP server specified in the config. If the SMTP server requires authentication, you’ll need to enter your password. If you send many patches, this can be tedious. You can save the password in the config, but note it will be stored unencrypted: git config --global sendemail.smtpPass 'your password' A better option might be to configure Git to cache your password for some time: git config --global credential.helper 'cache --timeout 3600' More advanced solutions can use password managers and the git-credential extension, but we won’t cover that here. Receiving and Integrating Patches Your team members receive your patch as a plain text email message, and they can review it—and, imagine that, reject your changes with requests to “fix” or “rewrite.” This is natural and the core of collaborative software development. The freedom and manual patch management are what attract developers to create their own information exchange solutions. What if You Are Asked to Fix Your Patch? Suppose developers ask to reduce calls to the Fprintf function and add a logging severity level. The updated code will look like this: package main import ( "fmt" "time" "os" ) type LogSeverity string const ( ERR LogSeverity = "ERROR" WARN LogSeverity = "WARN" INFO LogSeverity = "INFO" DEBUG LogSeverity = "DEBUG" ) func LogStderr(message string, severity LogSeverity, args ...interface{}) { x := time.Now() fmt.Fprintf(os.Stderr, "%s - %s - ", x.Format(time.RFC822), severity) fmt.Fprintf(os.Stderr, message, args...) fmt.Fprint(os.Stderr, "\n") } Since we’re fixing our previous patch and haven’t released any newer patches, we can simply amend the current commit: git commit -a --amend Now send the patch again, remembering we already configured the recipients: git send-email --annotate -v2 HEAD^ The -v2 flag means this is the second version of the patch. If you need another fix, use -v3, and so on. The --annotate flag allows you to add comments to your email message. Git will open a text editor showing something like: Subject: [PATCH v2] Logging function to stderr --- Added log level, reduced fmt.Fprintf calls Add your notes, save, and close the editor; the patch will then be sent again to the recipients. Always add annotations to your patches—it makes life easier for both you and your colleagues. Typing --annotate every time can get tedious, so you can automate it: git config --global sendemail.annotate yes How to Receive and Apply Patches? Receiving patches is a bit trickier. Git sends specially formatted patches in plain text email messages. There can be many such patches, and Git does not restrict the transport method (email, FTP, etc.), so it doesn’t handle how to receive patches—that’s up to the developer. Just use your mail client’s capabilities. After receiving approved annotated patches, save one or more email messages containing patches in an mbox file (Unix mailbox format). This format stores one or more email messages in a single file. Then run: git am <path_to_patches.mbox> All patches will be incorporated into your working copy. You can continue working and impressing your team. Email-based Git workflows can be as simple or sophisticated as you want. The main thing is that it suits the team and does not create unnecessary inconvenience. It seems there is nothing simpler, neater, or more elegant than working with Git over email. However, there is one major problem: distributing the working copy to new developers joining the project. If the project is large and has a rich history, the repository size might be many megabytes or even gigabytes. Sending that over email is impossible—it’s simply not designed for that. How to Provide a Newcomer with the Entire Project History? Git has an interesting feature called a bundle. It’s a snapshot of the working copy or the entire repository in a binary format of Git changes. Bundles are much more compact than a set of text patches; history and data inside the bundle are compressed, and the format allows transmitting both text and binary data. Project leads or other responsible persons can upload the current project bundle to a file-sharing service—for example, an FTP server or an S3-compatible object storage. The newcomer downloads the project bundle and clones it: git clone project.bundle <new_place> Now <new_place> contains a new working copy ready to work with email patches. However, to be honest, bundles are somewhat of an alternative to the patch email exchange workflow described above. Collaborative work using bundles is a different story.
07 July 2025 · 12 min to read
Git

Working with Git Tags

Git has been around for almost 20 years, yet it remains the most popular distributed version control system. It is best known for GitHub, the largest remote Git repository where developers store their code, document changes, and save previous versions. To help manage versions efficiently, Git provides special markers called tags. This article will explore what Git tags are and how to use them. What Are Git Tags? To understand Git tags, let's first clarify some related concepts. Commit: A commit is a saved version of a project. Branch: A collection of commits that visually represents the history of changes in a project. Multiple branches can exist simultaneously. Now, let’s define tags. Git tags are markers used to highlight important commits. They help track version history, as responsible developers often tag each new version. Like branches, Git tags point to a specific commit, but unlike branches, they do not have a history of commits. Now, let's see how to work with Git tags—create, view, publish, replace, switch, and delete them. How to Create Git Tags Git has two main types of tags: annotated and lightweight. Each is created differently. Creating Annotated Tags Annotated tags store complete version information, including developer names, emails, and timestamps. They are created using special Git flags, -a and -m, as shown in the example below: git tag -a ver-2.5 -m "beta version 2.5" git tag Output: ver-0.1 ver-1.6 ver-2.5 git tag is the main command for working with tags. -a creates an annotated tag with a specified identifier. -m adds a message. If omitted, a text editor will open for message input. To view details of an annotated tag along with its commit, use: git show ver-2.5 Output: tag ver-2.5 Tagger: Marianne Smith <m.smith@company.com> Date: Fri Mar 28 11:02:35 2025 beta version 2.5 commit bf93b7eaa928fd77a55453118313701b04874051 Author: James Brown <j.brown@company.com> Date: Mon Jan 6 09:41:02 2025 This displays the tagger's information, the commit hash, the author, and the creation date. To verify that the tag was created successfully, use: git tag -n Creating Lightweight Tags Lightweight tags are simple pointers to commits, typically used for temporary markers. They store only the commit’s hash. Here’s how to create one: git tag ver-2.5a git tag Output: ver-0.1 ver-1.6 ver-2.5 ver-2.5a ver-2.6 To view a lightweight tag's commit information: git show ver-2.5a Output: commit bf93b7eaa928fd77a55453118313701b04874051 Author: James Brown <j.brown@company.com> Date: Mon Jan 6 09:41:02 2022 -0300 Unlike annotated tags, lightweight tags do not store additional metadata. Adding and Deleting Git Tags in Remote Repositories To push a tag to a remote repository: git push origin ver-2.5 Here, origin refers to the default remote repository. To push all tags at once: git push origin --tags To delete a tag from a remote repository: git push origin --delete ver-2.5 To delete a tag locally (not on the remote repository): git tag -d ver-2.5 Switching Between Tags To switch to a specific tag: git checkout ver-2.5 However, this detaches the HEAD pointer, meaning any subsequent changes will not be associated with any existing branch. If you make changes, create a new branch to keep them: git checkout -b new-branch Viewing a List of Git Tags To list all available tags: git tag Output: ver-0.1 ver-1.6 ver-2.5 ver-2.5a ver-2.6 To filter tags using a pattern: git tag -l *xyz* If you have tags like ver-1.6xyz, ver-2.5xyz, and ver-2.6xyz, this command will output: ver-1.6xyz ver-2.5xyz ver-2.6xyz Reassigning or Replacing Tags To update an existing tag, use the -f flag for forced replacement: git tag -a -f ver-2.5a bf93b7eaa928fd77a55453118313701b04874051 This reassigns the tag to a specific commit hash. However, this will delete the old tag information, so use it carefully. Summary Git tags make version control more flexible and manageable. The commands covered here are simple yet powerful, making them easy to learn even for beginners. 
03 April 2025 · 4 min to read

Do you have questions,
comments, or concerns?

Our professionals are available to assist you at any moment,
whether you need help or are just unsure of where to start.
Email us
Hostman's Support