<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dmitrii Pavlov</title>
    <description>The latest articles on DEV Community by Dmitrii Pavlov (@dmjsdev).</description>
    <link>https://dev.to/dmjsdev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1074428%2F0a44188a-dcef-4259-9c06-128636d71ba1.png</url>
      <title>DEV Community: Dmitrii Pavlov</title>
      <link>https://dev.to/dmjsdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dmjsdev"/>
    <language>en</language>
    <item>
      <title>When HR wants a more experienced developer.</title>
      <dc:creator>Dmitrii Pavlov</dc:creator>
      <pubDate>Tue, 27 Jan 2026 15:50:50 +0000</pubDate>
      <link>https://dev.to/dmjsdev/when-hr-wants-a-more-experienced-developer-5akc</link>
      <guid>https://dev.to/dmjsdev/when-hr-wants-a-more-experienced-developer-5akc</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/IeucwGMHmDA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;“How many years of experience do you have?”&lt;br&gt;
“We’ve decided to move forward with a more experienced candidate.”&lt;/p&gt;

&lt;p&gt;Of course.&lt;/p&gt;

&lt;p&gt;Does this sound familiar?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Have 2+ Jobs? Use Git without letting them know about each other</title>
      <dc:creator>Dmitrii Pavlov</dc:creator>
      <pubDate>Thu, 12 Jun 2025 15:18:15 +0000</pubDate>
      <link>https://dev.to/dmjsdev/have-2-jobs-use-git-without-letting-them-know-about-each-other-1l8a</link>
      <guid>https://dev.to/dmjsdev/have-2-jobs-use-git-without-letting-them-know-about-each-other-1l8a</guid>
      <description>&lt;p&gt;&lt;em&gt;(or just want to separate work and personal projects)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let’s say you’ve been using GitHub under your personal identity — maybe something like &lt;code&gt;TrollCoder&lt;/code&gt;. Everything’s been smooth until you get hired, they give you a corporate email, and set you up with a company GitHub or GitLab account.&lt;/p&gt;

&lt;p&gt;Suddenly, you're expected to use your real name and photo in commit history — but your next commit to a work project shows up as &lt;code&gt;TrollCoder&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2618gt342ngsjs7vph6r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2618gt342ngsjs7vph6r.png" alt="Screen with a commit history and a TrollCoder nickname in it" width="784" height="134"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;😱 Awkward. Especially if your Git identity shows ties to a &lt;em&gt;different&lt;/em&gt; company...&lt;/p&gt;

&lt;p&gt;Bottom line: if you work for multiple clients or just want clean separation between personal and professional activity — it's crucial to manage Git identity per project.&lt;/p&gt;

&lt;p&gt;A few Git facts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git stores your name and email globally.&lt;/li&gt;
&lt;li&gt;This info ends up in every commit.&lt;/li&gt;
&lt;li&gt;Unless configured correctly, you risk leaking personal info into work repos (and vice versa).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s fix that.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1 — Check your current Git identity
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.name
git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.email
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If nothing is set globally, check your local project config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config user.name
git config user.email
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2 — Use conditional Git configs per folder
&lt;/h2&gt;

&lt;p&gt;The idea is to define separate Git profiles depending on the folder path.&lt;/p&gt;

&lt;p&gt;Let’s say you work for a company called &lt;code&gt;abcdefg&lt;/code&gt;. In your &lt;code&gt;~/.gitconfig&lt;/code&gt;, add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[includeIf "gitdir:~/mydevfolder/"]
    path = ~/.gitconfigs/.gitconfig-personal

[includeIf "gitdir:~/mydevfolder/abcdefg/"]
    path = ~/.gitconfigs/.gitconfig-abcdefg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What’s happening here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Any repo under &lt;code&gt;~/mydevfolder/&lt;/code&gt; will use your &lt;strong&gt;personal&lt;/strong&gt; Git config.&lt;/li&gt;
&lt;li&gt;Repos under &lt;code&gt;~/mydevfolder/abcdefg/&lt;/code&gt; will use your &lt;strong&gt;work&lt;/strong&gt; Git config for company &lt;code&gt;abcdefg&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 3 — Create the config files
&lt;/h2&gt;

&lt;p&gt;First, make a place to store them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; ~/.gitconfigs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Personal config (~/.gitconfigs/.gitconfig-personal)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[user]
    name = Troll Coder
    email = troll.coder@gmail.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Work config (~/.gitconfigs/.gitconfig-abcdefg)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[user]
    name = John Smith
    email = john.smith@abcdefg.com 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Now anytime you commit inside a project under &lt;code&gt;abcdefg&lt;/code&gt;, Git will correctly attribute the commit to your work identity — no more accidental &lt;code&gt;TrollCoder&lt;/code&gt; showing up in corporate history.&lt;/p&gt;




&lt;h2&gt;
  
  
  Wrap-up
&lt;/h2&gt;

&lt;p&gt;This setup helps you avoid identity leaks between work and personal repos, keeps your commit history clean, and saves you from embarrassing mistakes — especially if you freelance or contribute to OSS on the side.&lt;/p&gt;

&lt;p&gt;If you found this helpful, give it a ❤️ and share it with your team.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>DO comment your TS code</title>
      <dc:creator>Dmitrii Pavlov</dc:creator>
      <pubDate>Wed, 14 Feb 2024 04:26:32 +0000</pubDate>
      <link>https://dev.to/dmjsdev/do-comment-your-ts-code-1bl4</link>
      <guid>https://dev.to/dmjsdev/do-comment-your-ts-code-1bl4</guid>
      <description>&lt;p&gt;Once, while creating a module of code that is complex in its logic, I noticed that I wasn't following any rules of code commenting at all. All comments were scattered with different syntax, distracting from the code and providing no benefits.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;me&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;CommonFrontend&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;World&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

&lt;span class="c1"&gt;// Your code isn't as complex as you think&lt;/span&gt;
&lt;span class="nx"&gt;me&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;has_need_for_writing_articles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/** Why are you writing this? */&lt;/span&gt;
&lt;span class="cm"&gt;/**
 * TODO - 
 */&lt;/span&gt;
&lt;span class="nx"&gt;me&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write_article_for_myself&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// =========&lt;/span&gt;
&lt;span class="c1"&gt;// ! Warning: This article is too simple and no one needs it&lt;/span&gt;
&lt;span class="c1"&gt;//-   Don't write&lt;/span&gt;
&lt;span class="c1"&gt;// =============&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;World&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;has_someone_who_needs_this&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;me&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;go_on&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everyone knows the difference between single-line and multi-line comments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This is a single-line comment&lt;/span&gt;

&lt;span class="cm"&gt;/**
 * This is a multi-line comment
 */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;HOWEVER:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// I can&lt;/span&gt;
&lt;span class="c1"&gt;// do this multi-line&lt;/span&gt;

&lt;span class="cm"&gt;/** or do this single-line */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, comments in the &lt;code&gt;/** */&lt;/code&gt; format are recognized as documentation of function, class, or method, while &lt;code&gt;//&lt;/code&gt; comments are not. So, I started describing entire code blocks with &lt;code&gt;//&lt;/code&gt; comments (even if they span multiple lines), but variables and functions with &lt;code&gt;/** */&lt;/code&gt; comments only (preferably exactly in a single line, as they are more common in your code).&lt;/p&gt;

&lt;p&gt;Now, when hovering over a function anywhere in the code, I see the comment written above it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwtn4sfzg9ae58013jlf6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwtn4sfzg9ae58013jlf6.png" alt=" " width="367" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, a comment that would describe an entire block or file would hinder understanding the purpose of a function, as it would also be displayed in the popup-description as a documentation of that one exact function.&lt;/p&gt;

&lt;p&gt;Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Description of some blocks in a file&lt;/span&gt;
&lt;span class="c1"&gt;// Some facts that should be known about classes here&lt;/span&gt;
&lt;span class="cm"&gt;/** 
 * Class description
 * Some
 */&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CorrectCommentedClass&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cm"&gt;/** described */&lt;/span&gt;
    &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

    &lt;span class="cm"&gt;/** described */&lt;/span&gt;
    &lt;span class="nf"&gt;method&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// use such a comment to describe some strings in a functions' body as well    &lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Secondly, unused and often buggy code remained behind comments, which we simply forgot about and couldn't find again. To avoid this, use keywords in &lt;code&gt;/** */&lt;/code&gt; and &lt;code&gt;//&lt;/code&gt; comments both:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;!DEPRECATED&lt;/code&gt; - for explicitly outdated code that should be replaced or has already been removed in some places.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TODO&lt;/code&gt; - to denote code that needs further implementation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FIXME&lt;/code&gt; - for obvious bugs or potential issues that need to be fixed as soon as possible.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;*KLUDGE&lt;/code&gt; - description of necessary workarounds and illogical pieces of code, followed by a description of "why?".
These keywords and signs at the beginning are highlighted by the &lt;a href="https://marketplace.visualstudio.com/items?itemName=aaron-bond.better-comments" rel="noopener noreferrer"&gt;BetterComments&lt;/a&gt; extension for example or by default (depends on IDE), and you can search for them using these keywords.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And, forgive me, but I really do use this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;?WTF&lt;/code&gt; - for parts of the code that I completely don't understand and don't have time to figure out, hoping that one of my colleagues will see this in the code and leave a comment next time.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/** !DEPRECATED - why? where is new code? */&lt;/span&gt;
&lt;span class="cm"&gt;/** TODO - what? */&lt;/span&gt;
&lt;span class="cm"&gt;/** *KLUDGE - why? what is it for? */&lt;/span&gt;
&lt;span class="cm"&gt;/** FIXME - describe the bug */&lt;/span&gt;
&lt;span class="cm"&gt;/** ?WTF */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And this brings us to the conclusion:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write comments for your code. Sometimes I write them before writing the main code - it helps to think through how exactly it should work.&lt;/li&gt;
&lt;li&gt;Every time you need to take a break or have a minute, write comments for the code adjacent to yours.&lt;/li&gt;
&lt;li&gt;Sometimes enter keywords in the search in your IDE, and, if possible, refine &lt;code&gt;FIXME&lt;/code&gt; and explain to your colleagues &lt;code&gt;?WTF&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TU, and write what you think in comments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;World&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;has_someone_who_needs_this&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Proper use of git for beginners and beyond</title>
      <dc:creator>Dmitrii Pavlov</dc:creator>
      <pubDate>Sun, 30 Apr 2023 17:11:17 +0000</pubDate>
      <link>https://dev.to/dmjsdev/proper-use-of-git-for-beginners-and-beyond-4fem</link>
      <guid>https://dev.to/dmjsdev/proper-use-of-git-for-beginners-and-beyond-4fem</guid>
      <description>&lt;p&gt;I have noticed that many programmers neglect the rules outlined below, or don't know about them. Nevertheless, following these rules can standardize the work of both large and small teams using git, avoid problems and errors in dev branches, and on production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6q8hkfqkgaplfa202h3w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6q8hkfqkgaplfa202h3w.png" alt="git meme" width="700" height="907"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It is important to note that I am not a git guru and don't know all the commands and features, but I hope that this article will be useful&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  "We always push to master"
&lt;/h2&gt;

&lt;p&gt;The first rule that needs to be followed is to separate branches for production and development. I usually use the &lt;code&gt;main&lt;/code&gt; and &lt;code&gt;develop&lt;/code&gt; branches. The &lt;code&gt;main&lt;/code&gt; branch is usually automatically deployed with each change, while the &lt;code&gt;develop&lt;/code&gt; branch is used for development but there are no errors and all the functionality is completed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdwc9q5ncfjrx39jixrcm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdwc9q5ncfjrx39jixrcm.png" alt="gitflow scheme" width="800" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As shown in the diagram, any changes to the &lt;code&gt;main&lt;/code&gt; branch come only from the &lt;code&gt;develop&lt;/code&gt; branch (which may be linked to some test environment), but no one works directly with the &lt;code&gt;develop&lt;/code&gt; branch. Every task should start with inheriting from &lt;code&gt;develop&lt;/code&gt; and creating a new branch. Any fixes should be made in a separate branch and then merged into &lt;code&gt;develop&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In cases where a task affects a large functionality, especially if it requires the involvement of multiple developers, it is necessary to inherit from develop into a separate "EPIC" branch. They can have sequential numbers &lt;code&gt;EPIC-100&lt;/code&gt;, &lt;code&gt;EPIC-101&lt;/code&gt; ... or reflect the essence &lt;code&gt;EPIC-notifications&lt;/code&gt;. Each developer working on this "EPIC" should inherit from it and merge their completed task directly into it.&lt;/p&gt;

&lt;p&gt;With this hierarchy, it becomes possible to delegate tasks to developers of different levels. For example, you can allow push to &lt;code&gt;develop&lt;/code&gt; only to team-leads and senior programmers. And for some tasks, you can give full control of EPICs to middle developers so that they can control the merging of tasks of juniors and be responsible for the code quality in the EPIC. This will minimize errors and distribute responsibility for the project to all developers according to their abilities. And your branch will always be yours - sudden desynchronization of the local and remote server due to unsynchronized pushes of different programmers will not happen.&lt;/p&gt;

&lt;h2&gt;
  
  
  Something is wrong - we need to roll back
&lt;/h2&gt;

&lt;p&gt;Sometimes one of the developers working on a project may accidentally introduce incorrect changes (due to inexperience, carelessness, or simply because his changes did not negatively affect local development). And sometimes it can be very difficult to find and fix the cause of newly appearing bugs and errors.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Recently, I witnessed a situation where an obscure error occurred after 8 commits on top of the last correct version of the application and over 200 changed files.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In such cases, rolling back is necessary.&lt;/p&gt;

&lt;p&gt;Suppose we need to roll back the last 2 commits, which we believe contain the error. This can be done in 2 ways:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git revert HEAD~2..HEAD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That creates 2 new commits that undo the changes of the previous commits. This means that the commit history remains unchanged (new commits with changes are added).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset &lt;span class="nt"&gt;--hard&lt;/span&gt; HEAD~2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That undoes the changes made in one or more commits, completely removing them from the commit history.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;!!! I strongly advise against using the second option !!!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Firstly, it permanently deletes commits in which, in addition to the error, there may be useful code written by other developers, which may be needed to create new commits after the rollback.&lt;/p&gt;

&lt;p&gt;Secondly, this will undoubtedly cause synchronization problems with other developers, since the commit history in the remote repository will be changed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkkgf14yzviq5bjjdl8sm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkkgf14yzviq5bjjdl8sm.png" alt="Git meme" width="505" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To summarize - use &lt;code&gt;git revert&lt;/code&gt;,&lt;br&gt;
...or &lt;code&gt;git reset --hard&lt;/code&gt;, but you must understand what you are doing.&lt;/p&gt;
&lt;h2&gt;
  
  
  Proper committing and merging
&lt;/h2&gt;

&lt;p&gt;Such situations should happen extremely rarely and should be minimized as much as possible.&lt;/p&gt;

&lt;p&gt;1) To do this, you should always understand what you are pushing to the remote repository and forget about the command &lt;code&gt;git add .&lt;/code&gt; forever. Instead use the UI of your IDE to add files to the commit. In VSCode and WebStorm, you can view all modified files and click &lt;code&gt;+&lt;/code&gt; on those you are sure that the changes were not accidental keystrokes, but your meaningful changes.&lt;br&gt;
2) The code in your branch should be committed for each small but complete change. And the commit message should contain enough information: the task number or name and a brief description of what you have done. For example, "Notifications - creating a class for connecting to websockets."&lt;br&gt;
3) But in EPIC branches and other shared branches where your commit will be merged, there should be only one commit with a reference to your branch. To do this, merging into this branch should be done with the flags &lt;code&gt;--no-commit&lt;/code&gt; and &lt;code&gt;--squash&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# In a some EPIC branch:&lt;/span&gt;
git merge your-branch &lt;span class="nt"&gt;--no-commit&lt;/span&gt; &lt;span class="nt"&gt;--squash&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will not immediately merge your branch, but will only apply all the changes from your branch to the shared branch. You can view them in the UI of your IDE and double-check if you are sure about each modified file in the shared branch. After that, you can commit with a description that contains the branch name and the name of the merged branch. For example, "Site-sidebar - Notifications merged."&lt;br&gt;
4) After merging into the shared branch, especially into the develop branch, you should test the functionality of your feature and the areas that you think could have been affected by your code changes. If everything works correctly, you can push the shared branch with the merge commit to the remote repository.&lt;br&gt;
5) Merging into develop should be done in the same way as described above. EPIC branches, verified before, can contain many commits for each completed task. Now each EPIC needs to be merged into develop with one commit. "Site-sidebar merged". After some time, when the tasks prove their worth in action, task branches can be deleted from the repository (this can be done after a certain period, for example, 1-2 months, depending on the pace of your team's work). &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Don't forget to use "merged" word in a description to differentiate regular commits from merging&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Some Tips
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzorqkupywfgtyugm1oib.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzorqkupywfgtyugm1oib.png" alt="git meme" width="560" height="678"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;1) Writing Git commands with all flags and parameters can be tiresome for programmers who are not used to typing blindly with 10 fingers, especially if they have to enter them constantly.&lt;br&gt;
Personally, I use OhMyZsh to simplify some commands. If you're not a Windows user, I highly recommend it. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcmsg &lt;span class="s1"&gt;'first commit'&lt;/span&gt;
&lt;span class="c"&gt;# This is the same as&lt;/span&gt;
&lt;span class="c"&gt;# git commit -m 'first commit'&lt;/span&gt;

gco develop
&lt;span class="c"&gt;# git checkout develop&lt;/span&gt;

gcb new-branch
&lt;span class="c"&gt;# git checkout -b new-branch&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) If you use VSCode, like I do, take a look at the Git Graph extension. Typing in the console is always faster than using the mouse to navigate, but sometimes it's hard to orient yourself in the project without a good GUI.&lt;/p&gt;

&lt;p&gt;3) Even with this work structure, problems and errors arise. And here it is extremely important to understand how it is easier for you to communicate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write comments on completed tasks in your task managers with a description of the current branch state (possibly with a description of new errors and necessary scripts to run the application),&lt;/li&gt;
&lt;li&gt;Mark yourself in messengers about your status&lt;/li&gt;
&lt;li&gt;Divide your general meetups into smaller ones - for those working on a specific epic.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>git</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
