<?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 Krystian Szpiczakowski on Medium]]></title>
        <description><![CDATA[Stories by Krystian Szpiczakowski on Medium]]></description>
        <link>https://medium.com/@kszpiczakowski?source=rss-2f645dc7423c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*a3rV-H65d1yDoRX9xqyAiw.png</url>
            <title>Stories by Krystian Szpiczakowski on Medium</title>
            <link>https://medium.com/@kszpiczakowski?source=rss-2f645dc7423c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 02:21:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kszpiczakowski/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[New Year’s resolutions of a software developer]]></title>
            <link>https://medium.com/@kszpiczakowski/new-years-resolutions-of-a-software-developer-9cbc3b74be7b?source=rss-2f645dc7423c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cbc3b74be7b</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[personal-development]]></category>
            <dc:creator><![CDATA[Krystian Szpiczakowski]]></dc:creator>
            <pubDate>Mon, 09 Jan 2023 22:10:34 GMT</pubDate>
            <atom:updated>2023-01-09T22:10:34.526Z</atom:updated>
            <content:encoded><![CDATA[<h4>What are my goals for 2023?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nrfyKs9BH8Pq7H-c" /><figcaption>Photo by <a href="https://unsplash.com/@clemensvanlay?utm_source=medium&amp;utm_medium=referral">Clemens van Lay</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>2022 has gone dangerously fast, hasn’t it? I’m afraid that 2023 won’t slow down at all, and maybe it will pass even faster (I’m already beginning to understand what adults meant when I was a child, and when they said to each other that time passes so quickly).</p><p>This is why it’s so important to thoroughly plan the year that has just started — at the end of this year, I want to say with a clear conscience that I took care of my personal and professional development and am better than a year ago.</p><p>However, before I enter this year for real, I would like to share with you my achievements from the past year.</p><h3>How was 2022?</h3><p>I can say that 2022 introduced lots of changes in my personal and professional sphere:</p><ul><li>I landed a new job as a senior developer for implementations of Guidewire Software¹</li><li>I passed several Guidewire certifications, including ClaimCenter 10 Ace and upgrades to cloud versions</li><li>I began writing articles on Medium</li><li>Because I do love good coffee, I launched my polish YouTube channel², where I explain coffee-related stuff</li></ul><h3>New Year, New Me</h3><p>Buff, it’s January 9th, so it’s not too late with New Year’s resolutions yet. See what’s been running in my head for this year:</p><ul><li>I’ve been learning about cloud-oriented programming — I’m halfway through reading Sam Newman’s book³ about microservices, which seems a great starting point</li><li>I’m going to start preparation for Google Cloud Developer certification, and <em>I’m going to pass the exam</em></li><li>I’m finishing off writing the series about Git for everyone, a.k.a. <em>Meet Git⁴</em>, so I’ll have more time for writing about more technical stuff (like cloud programming)</li><li>I want to make videos on YouTube more regularly (once per month would be considered as good progress compared to the last year)</li><li>Morning workout at the gym twice per week (this has undoubtedly a high priority, as being healthy allows to realize everything else)</li><li>Deepen my cooking knowledge to cook quickly and tasty to save time</li></ul><h3>Summary</h3><p>In my opinion, the plan above is kind of ambitious. Will I manage this?</p><p>Well, apart from 9 to 17 job, writing articles on Medium, making videos about coffee, and preparing for cloud certifications, the most important badge waiting for me this year is to become a dad!</p><p>I definitely need to improve my time management skills and make the most of every free moment. So, forget scrolling walls, forget about watching Netflix.</p><p>This year promises to be quite intense, but also exciting as never before! Wish me luck :)</p><h3>References</h3><p>[1] Guidewire Software <a href="https://www.guidewire.com/">https://www.guidewire.com/</a></p><p>[2] Krystian Szpiczakowski on YouTube <a href="https://www.youtube.com/@speechakovsky">https://www.youtube.com/@speechakovsky</a></p><p>[3] Newman, S. (2021). <em>Building Microservices: Designing Fine-Grained Systems</em> (2nd ed.). O’Reilly Media.</p><p>[4] Krystian Szpiczakowski, <em>Meet Git</em> series <a href="https://medium.com/@kszpiczakowski/list/git-for-everyone-99f252099d8a">https://medium.com/@kszpiczakowski/list/git-for-everyone-99f252099d8a</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cbc3b74be7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Give some fireworks to your cookbook (Meet Git #9)]]></title>
            <link>https://medium.com/codex/give-some-fireworks-to-your-cookbook-meet-git-9-86e4f48becda?source=rss-2f645dc7423c------2</link>
            <guid isPermaLink="false">https://medium.com/p/86e4f48becda</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Krystian Szpiczakowski]]></dc:creator>
            <pubDate>Mon, 09 Jan 2023 16:51:37 GMT</pubDate>
            <atom:updated>2023-01-10T13:20:08.770Z</atom:updated>
            <content:encoded><![CDATA[<p>Can Git handle MS Word/LibreOffice documents?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OK3CgAc-e0hwdNeA" /><figcaption>Photo by <a href="https://unsplash.com/@rayhennessy?utm_source=medium&amp;utm_medium=referral">Ray Hennessy</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Previously, we were working on our first recipe in the cookbook. If you haven’t read my previous articles, I encourage you to start here¹, where we started off with a new Git repository, and we kept improving the <em>Royal Breakfast</em> recipe.</p><p>Up until now, we’ve been editing the recipe as a plain .txt file. Although this format is suitable if the only goal is to store text, it can’t hold information about headings, table of contents, font colors and so on.</p><p>Because we want our cookbook to have a more professional feel, the next step is to add formatting to it. How can we achieve this? Let’s move from plain text to rich text document!</p><h3>Make the cookbook more appealing</h3><h4>Create a new MS Word document</h4><p>First, let’s move the entire recipe to a newly created .docx document, and create a commit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bEldCvLHK99wTL8cN_vjXg.png" /><figcaption>The recipe saved as Microsoft Word document</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*ePWDc1monNyDYBMVP51Rag.png" /><figcaption>Stage the .docx document</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*II1BdA99dccJZiP-BabT2w.png" /><figcaption>Create a commit with a meaningful name</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DShRaaqJOyLk8Hy1xvN9_g.png" /><figcaption>The new snapshot is available in history</figcaption></figure><h4>Sprinkle some formatting on top of breakfast</h4><p>I’ve added a title, headings, and changed font types. It’s time to create another commit that will include these changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KbtNho259YnGHtI2M0JFXA.png" /><figcaption>Breakfast recipe includes formatting</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eki9S8JgFoRTNpvYGJxSPw.png" /><figcaption>Added commit with the formatted document</figcaption></figure><h4>Add a picture of breakfast</h4><p>It would be nice to show our readers what breakfast looks like, so they know what to expect from this recipe. Let’s add a picture, then.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RMpSwanb0nfTUGogU4nDLQ.png" /><figcaption>Added a picture of breakfast</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v-Nz52G_5G53kdAr5-1ZdQ.png" /><figcaption>Another snapshot with the picture has been created</figcaption></figure><h3>What about history?</h3><p>As you can see, everything in history seems fine. Each snapshot represents a point in time, so we can easily revert the recipe if needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*syBASefh6KE2Jc9l-pZyTA.png" /><figcaption>Three commits representing changes in MS Word document</figcaption></figure><p>Let’s compare differences between commits 2129442 and 7380968. As you can see, git diff 2129442..7380968 doesn’t say much. It’s because MS Word files are not really text documents, even if they may look so. For Git, such documents are <em>binary files</em>, which means there’s no way to check differences between snapshots.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qXCC6Q0wcIk6pIraYJ0w4A.png" /><figcaption>Comparing binary files doesn’t say much</figcaption></figure><p>Even if we’re using a modified version of the command above, i.e. git diff --binary 2129442..7380968, the returned message is quite cryptic, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YRjjf2amVzRhbC1Ut9PN_w.png" /><figcaption>Comparing commits with the “binary” flag isn’t meaningful, too</figcaption></figure><h3>Should I store binary files in Git?</h3><p>As a general rule, Git excels at storing text documents. In our case, however, the recipe stored as the .docx file, which is binary, makes Git doesn’t know how to compare differences between snapshots.</p><p><strong>Here are pros of using binary files in Git:</strong></p><ul><li>we can still use Git to store snapshots</li><li>if you want, you can use git reset to undo changes introduced in history, but you’ll lose affected commits</li></ul><p><strong>There are some serious drawbacks, though:</strong></p><ul><li>we can’t see the exact differences between commits</li><li>we can’t use git revert to undo changes introduced in previous commits, because Git is unable to see the difference between snapshots</li><li>using more advanced commands like git merge and git rebase to manipulate history is also impossible</li></ul><h3>Is there any alternative?</h3><p>You may be wondering if there are any alternatives to produce documents more interesting than just plain .txt files, which are more Git-friendly than .docx at the same time. There are a few methods to achieve this goal out there, and we’ll take a closer look at one of them in the next article.</p><h3>References</h3><p>[1] Krystian Szpiczakowski, <em>How to start cooking with Git (Meet Git #4)</em> <a href="https://medium.com/codex/how-to-start-cooking-with-git-meet-git-4-a286e4e08109">https://medium.com/codex/how-to-start-cooking-with-git-meet-git-4-a286e4e08109</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86e4f48becda" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/give-some-fireworks-to-your-cookbook-meet-git-9-86e4f48becda">Give some fireworks to your cookbook (Meet Git #9)</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Undo your breakfast (Meet Git #8)]]></title>
            <link>https://medium.com/codex/undo-your-breakfast-meet-git-8-433a1c6cb1e1?source=rss-2f645dc7423c------2</link>
            <guid isPermaLink="false">https://medium.com/p/433a1c6cb1e1</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Krystian Szpiczakowski]]></dc:creator>
            <pubDate>Thu, 29 Dec 2022 05:12:48 GMT</pubDate>
            <atom:updated>2022-12-29T05:12:48.306Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to revert changes in Git</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2ZXNxIyiWeoA3FfP" /><figcaption>Photo by <a href="https://unsplash.com/@jannerboy62?utm_source=medium&amp;utm_medium=referral">Nick Fewings</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Hello and welcome to the next article of a series devoted to the Git basics (not only) for programmers.</p><p>Leveraging Git in your workflow, you can store changes made within your files safely and effectively. Sometimes, however, you may realize that you told Git to keep track of something that in fact should not be recorded.</p><p>Luckily, Git offers a few ways to undo changes in history, and each of these can be used in different situations, which I’m going to explain in this article.</p><p>Let’s get started!</p><h3>Possible scenarios of undoing changes</h3><p>There are a few possible reasons and stages at which you would want to revert changes in Git — consider the following examples below:</p><ul><li>unstage changes if they are not committed yet</li><li>undo changes that have already been committed</li></ul><p>You should be already familiar with terms such as <em>staging area/index</em> and <em>commit</em>. If not, I encourage you to read my previous articles in this series.</p><h3>Undo changes if they are not committed</h3><p>Let’s imagine this scenario:</p><blockquote>You have introduced changes to the famous Royal Breakfast¹, you saved the file in your favorite text editor, and you closed your laptop because it’s time to go sleep. <strong>You decided not to create a commit of your work yet</strong>, though, because you know it’s just a draft version of your new idea.</blockquote><blockquote>The next day, you woke up with a fresh mind, and you came to the conclusion the new idea is crap, and it’s better not to change anything, because the Royal Breakfast is already perfect.</blockquote><blockquote>It turns out it’s too late to revert changes in the recipe, because the file has already been saved, and the undo operation in your text editor most likely does not work, since you closed the editor earlier.</blockquote><p>Oh, did I say that it’s too late? With Git, not at all, just use git reset, git checkout, or both to bring your modified file to the original state (the state represented by your last commit). Let’s find out which command is relevant in what situation.</p><h4>Changes are not staged</h4><p>Which command are you supposed to use to revert a file, given you haven’t staged changes yet? Use git checkout -- &lt;file&gt;, which replaces the selected file with its version from the latest commit.</p><p>For example, I modified the recipe saved in royal_breakfast.txt, so I want to use git checkout -- royal_breakfast.txt. You can use also git checkout -- ., if you’d like to revert all <em>tracked</em> files in the current directory (and subdirectories too).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*cQWTVyK-eAaw_BUils2P2A.png" /><figcaption>The history consists of four commits</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*JpVXsVlS_t775o5bMRhTlw.png" /><figcaption>Decorate the plate with ketchup? Hmm…</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*32ycOirYAqJroGS-Qrb2iQ.png" /><figcaption>The recipe was modified, but changes are not staged yet</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*77xdqkUFyxOdcwFJdgpgLw.png" /><figcaption>With “git checkout”, You can easily align your working directory with the last commit</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*4_RIeoBodwBFM1005m8pKQ.png" /><figcaption>There is no ketchup at all after git checkout</figcaption></figure><p>You may be wondering why have I used git checkout instead of git restore, even if Git suggests using git restore after I typed git status. Well, the official Git’s documentation states clearly that this is an experimental feature that may change in the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*7WSOxy3KX4Y_Rq5URvI83g.png" /><figcaption>Some commands in Git are experimental, such as “git restore”</figcaption></figure><h4>Changes are already staged</h4><p>In case you have already staged changes with git add, but not committed them yet, you’ve got to perform just one additional step compared to the previous scenario.</p><p>First, you need to remove changes from the staging area by using git reset -- &lt;file&gt;, in my case this would be git reset -- royal_breakfast.txt. Then, you need to perform the same operation as described in the previous paragraph, that is git checkout -- royal_breakfast.txt.</p><p>And again, although Git suggests using git restore --staged, I will stick to the old method, unless git restore is no longer experimental.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*iHzjbwCmxW8qDOv1U0UkfA.png" /><figcaption>The change with ketchup is staged this time</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*Fpqw0jQeLiqtTii-iwBlGg.png" /><figcaption>First, move changes away from the staging area</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*qNLUmF1caFPkCuGfgQpKsg.png" /><figcaption>Then, restore your working directory from your last commit</figcaption></figure><h3>Undo changes that have already been committed</h3><p>However, sometimes it happens that unwanted changes have already made their way to the repository. Even though, Git offers a few ways to deal with it, so let’s check them out.</p><h4>If your mistaken commit should stay in history (git revert)</h4><p>The git revert command is very useful and straightforward to use. Moreover, this command provides a safe and clean solution to revert an unwanted commit — just type git revert &lt;commit_id&gt;.</p><p>What’s so special about git revert? It preserves the faulty commit, which means you’ll end up with Git history containing two commits: the faulty one, and the second that reverts the former.</p><p>First, let’s create two commits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*pf3QCeJtP45w8nxlynxMBA.png" /><figcaption>The first change contains ketchup decoration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*zgcPtmnhvUVwa64bupXt2A.png" /><figcaption>Ketchup decoration committed</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*Mea-mf0_xE73cRD014c2QA.png" /><figcaption>The second change contains artichokes</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*O9fpCCapvCg0fgMXxluhWA.png" /><figcaption>Commit with artichokes created</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*8ctrW-HK3ssw300C11molg.png" /><figcaption>History with two latest commits</figcaption></figure><p>Suddenly, you found out that the change coming along with the first commit should not be stored in the repository, but the second commit is fine and should stay as is. Namely, the commit de2df73 with ketchup decoration is something we want to get rid of, while the commit ab6091f should stay.</p><p>For this kind of scenarios, git revert is a perfect solution. To make things right again, I’ll just type git revert de2d.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*L7Oo0tdZETTrvcKOUA7GDQ.png" /><figcaption>The revert operation introduced a new commit on top of history</figcaption></figure><p>You may ask a question: <strong><em>“How do I know if the commit I want to get rid of should stay in history or not?”</em></strong></p><p>To provide a simple answer for a not-so-trivial question, for now, assume you should favor git revert over other methods if:</p><ul><li>the change you want to undo is not the latest commit in the current <em>branch</em>, or</li><li>the commit is already <em>pushed</em> to a remote repository, and was used by someone else</li></ul><p>Don’t worry if you don’t know what pushing means — it’s a concept used when you work with remote repositories, and for now I only work with the local repository.</p><p>If you think you don’t need the last commit (or the last few) in history, go for git reset, which I explained below.</p><h4>If the faulty commit can be deleted from history</h4><p>Let’s assume the last three commits in Git history are to be removed. Since I’ve been working on a local repository, I don’t share these commits with anyone, so I can safely delete them.</p><p>To delete three commits from history, usegit reset --hard HEAD~3. This command can be translated to something like this:</p><blockquote>“Move the HEAD pointer three steps backward, and recreate the working directory from the current commit”.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*AfTIUWjH4MENbJmsgnNqdw.png" /><figcaption>From now on, the current commit will be 27a28ac</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*sKkE-nDPLuNQ2g9RRwZNcg.png" /><figcaption>After performing “git reset”, Git is telling you what is the current commit</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*OLfMepU_r2iar0hlYRVbDQ.png" /><figcaption>Removing those three commits was successful</figcaption></figure><p>When we work with Git, we <em>always</em> point somewhere in the history using the HEAD reference.</p><p>If you move HEAD backward, you lose access to the history that’s ahead, which means the history looks like it never contained our faulty commit, that is de2d….</p><p>This command is useful, but make sure you know what you’re doing, otherwise you may lose a part of your history. If you want to remove a commit from history, but as a safety net you want changes related to that commit to keep in the working directory, use git reset HEAD~3, or git reset --soft HEAD~3. By using either of these two, you still have to manually revert changes from the working directory.</p><p>Of course, Git includes a safety button called git reflog that allows you to restore commits even after using git reset --hard, but that is definitely a topic for another article.</p><h4>If the faulty commit requires just an amendment</h4><p>Another super useful command that I use regularly is git commit --amend. With the command above, you can bring additional changes to an existing commit.</p><p>Say, you decided to add artichokes to the breakfast (I do love artichokes). Let’s introduce them to the recipe, and create a commit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*w6quGieHomvhcoDNHDnBGw.png" /><figcaption>Added artichokes to the recipe</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*7ITQp0SJK2vXNXgOGxWlig.png" /><figcaption>Artichokes are mentioned in the recipe</figcaption></figure><p>You read this recipe once, twice and notice that the information about artichokes is not very accurate. Will the reader know that you meant pickled artichokes? And will they know that they should drain the artichokes from the brine?</p><p>Let’s modify the recipe to include these details, then.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*A5g9hiRmIylUDza8-dcLag.png" /></figure><p>Normally, when changes are staged, you would create a brand-new commit that appears on top of history, like this below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*ELauEjn2A0RUMwwlrqN6wA.png" /><figcaption>Fixing the last commit by introducing another one works, but we can do better</figcaption></figure><p>Instead of creating a new commit, we can simply edit the existing one, given the commit we want to amend is the last one in history. To do this, simply type git commit --amend, and <strong>Git will incorporate your changes from the staging area to the existing commit</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*ZX-Cjt5qOPgm-DUnr2Gg9A.png" /><figcaption>Make sure changes for amending are staged</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*oSwVV8Y_fbtm1kMUKL0SGw.png" /><figcaption>Amending of the commit was successful</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*aIjpFHOgyE2fwyQqslp-MQ.png" /><figcaption>After amending, commit’s checksum was changed from 3353b7e to 2129442</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*s0l6dxEAVLs2_u4RfeJxUw.png" /><figcaption>From now on, one commit contains all required information</figcaption></figure><p>Watch out for commits that might have been already pushed, though, because the checksum of the amended commit was changed, and this can lead to nasty problems with keeping the history synchronized (and your colleagues will stop liking you).</p><h3>Bonus: resolving conflicts</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*Azxfyf_9Fv4K9QGIhsBA5Q.png" /><figcaption>A conflict has appeared that must be resolved</figcaption></figure><p>If you’re reverting a commit, and you’re seeing something like this, don’t panic. This message means that we’ve got <em>a conflict</em> that has to be <em>resolved</em>. I haven’t explained to you what conflicts are yet, but in short, conflicts occur when there are changes overlapping each other within a single file.</p><p>The good thing about Git is that it won’t leave you stranded with a mess — if you don’t know what to do, simply obey what Git is telling you, and type git revert --abort. This will bring you to the state before the conflict occurred.</p><p>The only thing left after this stressful situation is a set of files that you can safely delete. Before you do it, however, it might be useful to skim through them and see what’s the cause of this conflict.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*9Qr5GFRdOFvUqCLPQnfmZg.png" /><figcaption>If a conflict occurs, you can always step back and think over it</figcaption></figure><p>Because I aborted the conflict resolution with git revert --abort, let’s try again to revert the change by typing git revert de2d, and resolve the conflict.</p><p>When I opened the conflicted file, I can see markers that help me understand what’s going on.</p><p>Basically, the text between &lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD and ======= caused the conflict, and Git needs my help to decide what to do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*biIgEP9LQrxPKc8Eg7Lspw.png" /></figure><p>As you can see, I’ve added ketchup and artichokes side by side in the ingredients section, so Git isn’t sure what to keep and what to remove. We want to delete everything ketchup-related, so let’s tidy up this recipe a bit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*onVNXUnGmuYXOai8HPRxtA.png" /><figcaption>The recipe after conflict resolution</figcaption></figure><p>The recipe is fixed now — note, I also deleted markers that pointed to the conflicting spot.</p><p>Once I edited the file and saved it, I can move on to Git Bash and finalize the revert operation. To do it:</p><ul><li>add the conflicted file to the index</li><li>let Git continue reverting our changes by typing git revert --continue</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*tUdgl0kcfUNuJ8fNDvjc0g.png" /><figcaption>The resolved conflict still has to be added to the index</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*HGtWWH3HNEz7cTLhtr-C5w.png" /><figcaption>Resolved conflicts have to be moved to the index/staging area</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*LfQyLbldJQ1Hc_xSF-tNIw.png" /><figcaption>All conflicts have been resolved — let’s proceed with the revert operation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*L7Oo0tdZETTrvcKOUA7GDQ.png" /><figcaption>The revert operation introduced a new commit on top of history</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*YjNZEfqgdDhGL8OV6N-NQw.png" /><figcaption>The revert operation was successful — there is no ketchup in the recipe</figcaption></figure><p>In general, there are nice tools out there for resolving conflicts, but the presented conflict was quite simple, so the old good notepad was enough to fix it.</p><h3>References</h3><p>[1] Krystian Szpiczakowski, <em>How to start cooking with Git (Meet Git #4)</em> <a href="https://medium.com/codex/how-to-start-cooking-with-git-meet-git-4-a286e4e08109">https://medium.com/codex/how-to-start-cooking-with-git-meet-git-4-a286e4e08109</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=433a1c6cb1e1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/undo-your-breakfast-meet-git-8-433a1c6cb1e1">Undo your breakfast (Meet Git #8)</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Different Royal Breakfasts (Meet Git #7)]]></title>
            <link>https://medium.com/codex/different-royal-breakfasts-meet-git-7-1ecc9fb77ff?source=rss-2f645dc7423c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ecc9fb77ff</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Krystian Szpiczakowski]]></dc:creator>
            <pubDate>Sat, 17 Dec 2022 17:28:37 GMT</pubDate>
            <atom:updated>2022-12-17T17:28:37.107Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to check what has been committed and when</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Fgxy5i8EySXBhdau" /><figcaption>Photo by <a href="https://unsplash.com/@rossf?utm_source=medium&amp;utm_medium=referral">Ross Findon</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>A change is something that drives the progress of everything. Without changes, we would stick to a plain sandwich, but now we’ve got a quite decent breakfast.</p><p>Because changes are so important, today we’re going to take a look at how <strong>The Royal Breakfast</strong> was evolving in time. To achieve this, we’ll use git log, git diffand git show.</p><h3>Show what has been committed and when</h3><h4>Check details of the particular commit</h4><p>To recall, we’ve got three commits in our history, and say, we would like to <strong>check details of the first commit (</strong><strong>1033ca3)</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*t73glO3yi2ZWpGVaPDQdZQ.png" /><figcaption>Our recipe is a series of three commits</figcaption></figure><p>To get more information about that commit, type git log 1033ca3, or even shorter git log 1033, provided you can uniquely identify the commit. If you want to display all commits, just use git log, without specifying the commit’s checksum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*-9kjs4hpymxeP4PwSghYwA.png" /><figcaption>Display a single entry in git history by using git log</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*mA8DFPMiDpoaax69uSYgiQ.png" /><figcaption>Display all commits from history by using git log</figcaption></figure><p>As you can see, this doesn’t present the exact changes in the recipe, though. To find out what changes have been introduced by commit 1033ca3, use git show 1033ca3.</p><p>Apart from metadata, such as an author and commit date, you can see the all changes made within the royal_breakfast.txt recipe.</p><p>In general, git show &lt;commit_sha&gt; gives you details on what has been changed in a particular commit, <strong>compared to its parent</strong>. The first commit in Git repository is a bit special, though, because it has no parent commit!</p><p>How to know which commit is a parent of another? To get a nice view of history in your repository, and to see relationships between commits, I encourage you to create the git lga alias in Git. I have described the required steps here¹.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*oU269wYRfLChUHuvKWkHmg.png" /><figcaption>Display the exact changes within the file by using git show</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*lgMrINoUGonKTNZ9FWqrPw.png" /><figcaption>With git lga, you can easily figure out what history looks like</figcaption></figure><h4>Check differences between two versions of the breakfast</h4><p>If you would like to know, what differences are between a broader set of commits, use git diff from_revision..to_revision, for example, git diff 1033..cab78. In this particular example, Git will display changes introduced by c033 and cab78.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ho3BYpljviM4qUDLa154YA.png" /><figcaption>git diff lets you inspect a broader set of commits at once</figcaption></figure><h3>Show differences before you commit next changes</h3><p>The well known git diff command lets you not only review the history of already committed snapshots, but also helps you find out</p><ul><li>what has been changed since the last commit (e.g. if you modified the recipe with your favorite text editor)</li><li>what <em>is</em> to be committed (when you modified the recipe, and you’ve already staged changes, but haven’t committed them yet)</li></ul><h4>What has been changed since the last commit?</h4><p>To figure it out, you can use two commands:</p><ul><li>git status tells you which files were modified</li><li>git diff provides more detailed information and shows what exactly has been changed within tracked files</li></ul><p>There is one important note regarding using git diff. If you have a long line of text, and you’re changing only a few words within it, git diff may produce quite confusing output, like in the screenshot below.</p><p>At first glance, it looks like I changed a lot within royal_breakfast.txt. In reality, I have changed only a single word. The output looks as it looks because by default git diff detects whole lines that are modified. To get a better view of what I really changed, I used git diff --word-diff, which highlights only words that were changed. The output of this command has been shown in the next screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*rJ5hvYD09HJ5inPMqzgD_g.png" /><figcaption>git status displays names of modified files</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bekyjtrHS1lEMsengRm6VA.png" /><figcaption>git diff simply displays whole lines that have been changed</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3hCTxOljtu5MyBwhCIKmMQ.png" /><figcaption>Use git diff along with the “word-diff” flag in order to highlight only modified words in a single line.</figcaption></figure><h4>What changes are going to be committed?</h4><p>If you staged (prepared) changes for the next commit, git status should produce output as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*1RoKK4nm2-eznKAUbMimag.png" /><figcaption>Staged files are marked in green</figcaption></figure><p>What’s interesting, git diff doesn’t show any changes. It’s because git diff compares the working directory that is not staged. The royal_breakfast.txt has been already staged, so use git diff --cached instead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*dsbAxNqFSMgW3EJz58acEw.png" /><figcaption>git diff doesn’t present changes if they are staged</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*qKqnfTQhqCJZC2pqhHHopw.png" /><figcaption>Use git diff along with the “cached” flag to show staged changes</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*qArnB7SxXWjUuHrDM-Hgww.png" /><figcaption>Use the “word-diff” flag to display only words that have been changed</figcaption></figure><p>Under certain circumstances, Git displays information that may look even more confusing. Namely, if you type git status, Git can tell you that the same file is</p><ul><li>modified but not staged (marked in red)</li><li>modified and staged (marked in green)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*y8n1NQAi4owr4_gOlR9mqQ.png" /><figcaption>A file can be staged and not staged at the same time</figcaption></figure><p>This simply means, that you had modified a file and staged it. Later on, you decided to introduce another changes in the same file, without adding the file to the staging area again.</p><p>If I type git diff --word-diff, the output says I added <em>“chop chop”</em> in the text, and this change is not staged, because I used the command without the “cached” flag.</p><p>On the other hand, if I type git diff --cached --word-diff, the produced output says that the word <em>“Finely”</em> has been replaced with <em>“Roughly”</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*5C_xvBaX2TicuSgXWJwskw.png" /><figcaption>A change that has not been staged yet</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*3vUjnbpx4kjcPqgDcA1U3Q.png" /><figcaption>A change that has already been staged</figcaption></figure><p>If I committed the file as it is, my new commit would only contain the change from <em>“Finely”</em> to <em>“Roughly”</em>. Let’s see if my assumption is correct, then.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*icTO6xFHLe5lYwJk6XpOhQ.png" /><figcaption>A new commit with partial changes has been created</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*AdnEa7rhvas3HrY1fLueEg.png" /><figcaption>The new commit is present in git history</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*Ixg3aYSO8uDtHi1OKdaMLA.png" /><figcaption>The “git show” command presents the new commit contains only partial changes</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*qWwK3dVL3r3Laahy2hSogw.png" /><figcaption>Changes that were not staged are still available in the working directory</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*1r8wazky1nN9gYcdKNLJAg.png" /><figcaption>The “git diff” command confirms the change is in place</figcaption></figure><h3>Next steps</h3><p>Did I really want to roughly chop the onion? No, I didn’t. How to make breakfast royal again, then?</p><p>In the next article, I’m going to show you how to revert unwanted changes in a few ways, depending on the context.</p><p>Stay tuned!</p><h3>References</h3><p>[1] Krystian Szpiczakowski, <em>The History of The Royal Breakfast (Meet Git #6)</em> <a href="https://medium.com/codex/the-history-of-the-royal-breakfast-meet-git-6-b1a8a2b521ba">https://medium.com/codex/the-history-of-the-royal-breakfast-meet-git-6-b1a8a2b521ba</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ecc9fb77ff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/different-royal-breakfasts-meet-git-7-1ecc9fb77ff">Different Royal Breakfasts (Meet Git #7)</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The History of The Royal Breakfast (Meet Git #6)]]></title>
            <link>https://medium.com/codex/the-history-of-the-royal-breakfast-meet-git-6-b1a8a2b521ba?source=rss-2f645dc7423c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1a8a2b521ba</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Krystian Szpiczakowski]]></dc:creator>
            <pubDate>Thu, 17 Nov 2022 09:00:12 GMT</pubDate>
            <atom:updated>2022-11-18T01:24:47.418Z</atom:updated>
            <content:encoded><![CDATA[<h4>What are commits and how to read Git history?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Kprm-1ZD7VJ3Rpnf" /><figcaption>Photo by <a href="https://unsplash.com/es/@joannakosinska?utm_source=medium&amp;utm_medium=referral">Joanna Kosinska</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>In the previous article¹, we were finishing our first recipe in the cookbook. Today, you will learn basics about what are commits, how they relate to each other, and how to view the history of the repository.</p><p>Let’s get started!</p><h3>Commits explained</h3><h4>What are commits?</h4><p>Well, we’ve already created a few commits in the cookbook repository, but what they really are?</p><p>Every time you tell Git to save your changes by entering git commit, Git creates, as you can probably guess, a commit.</p><p>A commit is a snapshot of all staged via git add command changes that have happened since the previous commit. Every commit contains information such as:</p><ul><li>New changes to the previous snapshot</li><li>Author</li><li>Creation date</li><li>Message</li><li>SHA-1 checksum, for example cab78b27856…, where usually only the first few characters matter, as long as you can uniquely identify the commit</li></ul><h4>Where are commits stored?</h4><p>Where are these objects stored? As a reminder: within the .git subdirectory, so in our case cookbook/.git.</p><p>Luckily, we don’t need to know details about Git internals. What you need to remember is that <strong>your repository is the </strong><strong>.git directory</strong>. This means, even if you accidentally modify the recipe for Royal Breakfast, or you even delete the file named royal_breakfast.txt, restoring the recipe is for Git a breeze, as long as you have the .git directory in place.</p><h4>How do commits relate to each other?</h4><p>Regarding commits, <em>every</em> commit is linked to its parent commit. At this point, I would like to mention there are two special cases, that may occur:</p><ul><li>A first commit in the repository doesn’t have its parent commit</li><li>Merge commits can have more than one parent commit (we haven’t talked about merging yet, but I’ll show you this scenario in one of the next episodes)</li></ul><p>To better understand the association between commits, let me give you an example based on the cookbook repository.</p><p>The newest commit, cab78b2, is linked to c033558, which means that the parent of cab78b2 is c033558. Then, commit c033558, is linked to the initial commit in the repository, that is 1033ca3. Eventually, commit 1033ca3 has no parents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*k_dUp3ji9aXw9Nt5FBv3pQ.png" /><figcaption>Every commit is linked to its parent</figcaption></figure><h4>Don’t lose your HEAD</h4><p>Note one more thing: do you see that blue HEAD marker on the screenshot above? This is a so-called <em>pointer</em>, and it’s placed usually on top of the branch, if your workflow is straightforward (like in our case).</p><p>There are basically two main responsibilities of the HEAD pointer:</p><ul><li>It shows what state of the repository your working directory represents</li><li>It points where the next commit will be added to</li></ul><p>On the screenshot above, HEAD is pointing to the commit cab78b2. <strong>Location of </strong><strong>HEAD simply tells you that files in the </strong><strong>cookbook directory look just like when this commit was performed (unless you modified the text file with the Royal Breakfast recipe).</strong></p><p><strong>Also, if you are about to perform another commit, it will appear on top of </strong><strong>cab78b2, because this is where HEAD points to.</strong></p><p>Manipulating the HEADpointer is really useful, for example, if you want to bring your project to the previous known state. <strong>Traveling in time and reverting changes in Git is mainly associated with moving the </strong><strong>HEAD pointer, and this topic will be covered in the next episode.</strong></p><h4>About branching</h4><p>In terms of branching, I haven’t covered this topic yet, but for now you only have to know that each repository have at least one branch, and in our repository this branch is called master, or main, depending on your Git configuration. We <em>always</em> work in the context of a particular branch, so we can say that we’ve been working on our recipe on the master branch.</p><p>What does it mean? Commits organized like this allow you to do interesting things, for instance:</p><ul><li>comparing <em>what</em> changes have been introduced and <em>when</em></li><li>traveling in time/reverting changes if you change your mind</li></ul><h3>View the history</h3><p>In previous episodes, we created three modifications (commits) in our repository, but how to check what’s been introduced and when?</p><p>It’s easy to remember all these things when the project is super simple like now, but when the project grows, it’s getting more and more difficult to remember everything. To view and analyze the history, Git comes along with several tools that I’ll describe below.</p><h4>Using git log</h4><p>Using git log is the easiest way to find out what’s going on with the repository. <strong>The </strong><strong>git log command shows the history of the branch you’re currently working on</strong> (master, as there is only one branch in the entire repository). Each entry represents a single commit, and it consists of a set of vital information about the particular snapshot.</p><p>What’s important, the entries are ordered from the newest to the oldest, so if you want to check the history in chronological order, read the entries from the bottom up. This may seem odd at first, but we’re usually interested in recent changes, so that’s why they are listed first.</p><p>If the history contains so many commits that they don’t fit on a single page, use B (backward), F (forward) and Q (quit) keys on your keyboard to navigate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*plyEVvQSGJi0d6q-Wv5KwQ.png" /><figcaption>Recent changes are listed on top</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*zkHx6ZqBb94s85liyjzsbA.png" /><figcaption>Colon at the end means there are more pages to show</figcaption></figure><h4>Viewing history as a graph</h4><p>The simple git log is okay, but if you want to use Git really like a Pro, I have something better for you.</p><p>Now, let’s suppose that our cookbook will contain a few more recipes than it currently has. Moreover, if you want to develop recipes independently of other recipes, you will probably appreciate working on separate <em>branches</em>, and the history of the repository may look like the screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*FCnn-x-feAAhYYQQENaMPg.png" /><figcaption>The history of the repository represented as a graph</figcaption></figure><p>Every light green label, i.e. master, spaghetti_carbonara, tiramisu_omg, represents a separate branch. As you can see, <strong>the history is not linear anymore, so these recipes can be developed independently.</strong></p><p>In this scenario, the simple git log doesn’t work anymore. I mean, it does work, and it still produces output, but <strong>the output of </strong><strong>git log is limited to commits from the branch you are currently on</strong> (HEAD is pointing at master branch).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*FUJSk598P44k09Ajwb22Bw.png" /><figcaption>git log shows commits only from the current branch (master)</figcaption></figure><p>It’s much nicer to have a bigger picture of what the repository look like, for example what other branches exist in the repository, and how they merge, if at all.</p><p>To achieve this, <strong>I encourage you to start using </strong><strong>git log --graph --all --oneline --decorate.</strong></p><p>Here’s a short explanation of what particular flags do:</p><ul><li>--graph makes every commit is an asterisk connected with a line</li><li>--all displays <em>all</em> branches within the repository</li><li>--oneline condenses information about a single commit into one line</li><li>--decorate gives some extra formatting (depending on Git version, decorating can be enabled by default)</li></ul><h4>Aliases in Git</h4><p>That command is nice, but do we really have to re-type it over and over again, every time we want to use it?</p><p>I admit, the command displaying the history as a graph it’s a bit lengthy, and if I had to type it from scratch, this would drive me nuts.</p><p>Fortunately, Git has a cool feature called <em>aliases</em>. If you have a command that you often use, you can create an alias for such a command. This allows you, for example, to make the long commands much shorter.</p><p>What if I told you that instead of writing git log --graph --all --oneline --decorate you could just use git lga?</p><p>To make git lga available in Git, paste in the terminal git config --global alias.lga log --graph --all --oneline --decorate. This will add the new alias in the global scope, which means from now on, git lga will be available for your system account.</p><h3>What’s next?</h3><p>Since we haven’t exhausted the topic of checking the history yet, in the next episode we will find out how to check what exactly was committed and when.</p><h3>References</h3><p>[1] Krystian Szpiczakowski, <em>Make the Royal Breakfast truly royal (Meet Git #5)</em> <a href="https://medium.com/codex/make-the-royal-breakfast-truly-royal-meet-git-5-b7ba8a36f91">https://medium.com/codex/make-the-royal-breakfast-truly-royal-meet-git-5-b7ba8a36f91</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1a8a2b521ba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/the-history-of-the-royal-breakfast-meet-git-6-b1a8a2b521ba">The History of The Royal Breakfast (Meet Git #6)</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make the Royal Breakfast truly royal (Meet Git #5)]]></title>
            <link>https://medium.com/codex/make-the-royal-breakfast-truly-royal-meet-git-5-b7ba8a36f91?source=rss-2f645dc7423c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7ba8a36f91</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Krystian Szpiczakowski]]></dc:creator>
            <pubDate>Sun, 06 Nov 2022 12:07:36 GMT</pubDate>
            <atom:updated>2022-11-06T12:07:36.364Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to track new versions of your project and compare differences</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*waBf8D62M7EXaUuR" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hello and welcome to the fifth(!) article of the series about Git not only for developers.</p><p>Previously¹, we created a new repository and saved an initial version of the <strong>Royal Breakfast</strong>. I agree, it’s hard to call that breakfast <em>royal</em> in the current state, but now we have a good base to experiment with.</p><p>Today, you’ll learn:</p><ul><li>How to add new changes to the project</li><li>How to compare differences that will be committed</li><li>H̶o̶w̶ ̶t̶o̶ ̶r̶e̶a̶d̶ ̶t̶h̶e̶ ̶h̶i̶s̶t̶o̶r̶y̶ ̶o̶f̶ ̶t̶h̶e̶ ̶r̶e̶p̶o̶s̶i̶t̶o̶r̶y̶</li><li>H̶o̶w̶ ̶c̶o̶m̶m̶i̶t̶s̶ ̶a̶r̶e̶ ̶r̶e̶l̶a̶t̶e̶d̶ ̶t̶o̶ ̶t̶h̶e̶ ̶o̶t̶h̶e̶r̶ ̶o̶n̶e̶s̶</li></ul><h3>Add some goodies to breakfast</h3><h4>Check the repository status</h4><p>At this point, our working directory should not contain any changes compared to the repository. If Git says there’s nothing to commit, and working tree is clean, we can move on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*cHX3DhTiYz4VklLx-FDJRw.png" /><figcaption>The cookbook directory has no changes compared to the repository</figcaption></figure><h4>Edit the recipe</h4><p>Let’s add some vegetables apart from sprouts, for example avocado and tomatoes. The revised recipe looks as follows:</p><blockquote>Ingredients:<br>- 1 roll<br>- cream cheese<br>- sprouts<br>- 1/2 of avocado<br>- 3–4 cherry tomatoes</blockquote><blockquote>Preparation:<br>Cut the roll in half, spread cream cheese on the roll and lay out the sprouts.</blockquote><blockquote>Slice an avocado around the pit and halve it. Because we only need one half of the avocado, use the half that does not have a seed, and put the other one in the refrigerator. Pull the avocado out of the skin using a spoon. Put the avocado and cherry tomatoes on a plate, next to the roll.<br>To bring out the flavor of the avocado, add a pinch of salt and freshly ground pepper.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*sRYSAdih94wb9wtTCm3qfg.png" /><figcaption>The edited Royal Breakfast containing more vegetables</figcaption></figure><h4>Check the status after you saved the recipe</h4><p>Once you finished editing the recipe, and you saved the file, Git will notice that the file has been changed.</p><p>To check if Git has something interesting to say, you can use the command you already know, that is git status. This time, Git is telling you that royal_breakfast.txt is <em>modified</em>, which means Git already tracks this file, and knows what’s going on with the recipe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*F9fpOFhhW3b3I8HfOBNsBw.png" /><figcaption>Git is showing the recipe is modified</figcaption></figure><h4>What has been changed in the recipe?</h4><p>A really useful command that Git offers is git diff, which shows you what exactly has been changed in a text file.</p><p>The git diff command can be used in a few scenarios, for example:</p><ul><li>If you modified your file (e.g. edited the recipe in the notepad), but you haven’t staged these changes yet (so you didn’t use the git add command), use git diff without parameters, and this will show you the <strong>difference between the working directory and the <em>last commit</em></strong></li><li>If you modified the recipe, and you have already staged the changes using git add, use git diff --cached, which will show you the <strong>difference between changes you staged and the last commit</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*PmSlfx9MRN1wJ5ApWVrUxQ.png" /><figcaption>You can verify the exact changes using the ‘git diff’ command</figcaption></figure><h4>Add changes to the staging area</h4><p>I’m satisfied with modifications introduced in the recipe, so it’s time to stage and commit these changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*KqGOX3z8WwpF8g5cWGQqQg.png" /><figcaption>The green highlighted file means that the changes it contains will be committed</figcaption></figure><h4>What will be committed?</h4><p>Now, I already staged the change I want to commit, so git status is highlighting the royal_breakfast.txt file with green color. But what if you want to double-check what differences will be committed?</p><p>Let’s enter git diff once again. As you can see, the output is now empty, despite changes are waiting in the index/staging area for the next commit!</p><p>If I enter git diff --cached, however, the diff output is correct.</p><p>This particular situation is just a specific behavior of the git diff command that you have to keep in mind, otherwise you’ll be surprised what’s going on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*8RcHoplbmRwHP9zfRY888g.png" /><figcaption>The ‘git diff’ command shows no differences after moving changes to the index</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*fF0mhCriMy26SB_YH2V2tg.png" /><figcaption>Using ‘cached’ flag for ‘git diff’ command shows the differences after changes were already staged</figcaption></figure><h4>Save the new snapshot containing more vegetables</h4><p>Our changes are moved to the staging area, so they are ready to commit. Enter git commit -m &quot;Add more vegetables&quot;, and that’s it — the repository has another snapshot of our breakfast.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*pbGU275LGaOcz7lLN6foow.png" /><figcaption>Another changes in the recipe committed</figcaption></figure><h3>Let’s add some more goodies!</h3><p>My favorite part of breakfast, is frying scrambled eggs for me and my wife. Okay, I lied to you — more than cooking the scrambled eggs, I love eating them even more!</p><p>So let’s add the final part of the Royal Breakfast, the icing on the cake:</p><blockquote>Ingredients:<br>- 1 roll<br>- cream cheese<br>- sprouts<br>- 1/2 of avocado<br>- 3–4 cherry tomatoes<br>- 1/2 of onion<br>- a few slices of ham<br>- 2 eggs<br>- 1 tbsp of olive oil</blockquote><blockquote>Preparation:<br>Cut the roll in half, spread cream cheese on the roll and lay out the sprouts.</blockquote><blockquote>Slice an avocado around the pit and halve it. Because we only need one half of the avocado, use the half that does not have a seed, and put the other one in the refrigerator. Pull the avocado out of the skin using a spoon. Put the avocado and cherry tomatoes on a plate, next to the roll.<br>To bring out the flavor of the avocado, add a pinch of salt and freshly ground pepper.</blockquote><blockquote>Finely chop the onion. In a frying pan, heat the olive oil and fry the onion for one minute over medium heat. Add the ham and cook another minute. If, like me, you’re not a fan of mousse-like scrambled eggs, don’t whisk them before you add them to the pan — just gently mix the eggs directly on the pan. Add a pinch of salt. Control the fire and gently stir the eggs from time to time to prevent them from sticking to the pan. Finally, add freshly ground black pepper.</blockquote><blockquote>Enjoy!</blockquote><p>As you may have already guessed, you should now add the changes to the staging area (git add), and then commit them (git commit).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*2BqLiw4qh4oysoRmaUlxsQ.png" /><figcaption>More changes waiting to be added to the staging area</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*ZgZSNLWItCeCoprJ8ryYnA.png" /><figcaption>Changes have been added to the staging area</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nE91_yhZrm1ZndkT79hz5w.png" /><figcaption>Git is showing that the changes are related to scrambled eggs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*1pEao11iIHQ-7o5WZ5RErQ.png" /><figcaption>Finally, the Royal Breakfast includes scrambled eggs too</figcaption></figure><h3>The Royal Breakfast in all its glory</h3><p>At last, I can enjoy my favorite breakfast. But, didn’t I write at the beginning that I’ll explain commits and how to read the history of the repository?</p><p>Oh yeah, I’ll do it but in the next episode, because it turned out that this article has become as big as the Royal Breakfast.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aPa5wgMg3Ygd3gDriVxf9g.jpeg" /><figcaption>The Royal Breakfast in all its glory</figcaption></figure><h3>References</h3><p>[1] Krystian Szpiczakowski, <em>How to start cooking with Git (Meet Git #4)</em> <a href="https://medium.com/codex/how-to-start-cooking-with-git-meet-git-4-a286e4e08109">https://medium.com/codex/how-to-start-cooking-with-git-meet-git-4-a286e4e08109</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7ba8a36f91" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/make-the-royal-breakfast-truly-royal-meet-git-5-b7ba8a36f91">Make the Royal Breakfast truly royal (Meet Git #5)</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to start cooking with Git (Meet Git #4)]]></title>
            <link>https://medium.com/codex/how-to-start-cooking-with-git-meet-git-4-a286e4e08109?source=rss-2f645dc7423c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a286e4e08109</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Krystian Szpiczakowski]]></dc:creator>
            <pubDate>Thu, 27 Oct 2022 15:56:20 GMT</pubDate>
            <atom:updated>2022-11-02T14:56:31.068Z</atom:updated>
            <content:encoded><![CDATA[<h4>Create a Git repository and keep recording how your project evolves</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lJISEn6oB1zMfqOf" /><figcaption>Photo by <a href="https://unsplash.com/@jimiburg?utm_source=medium&amp;utm_medium=referral">Jimi Filipovski</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hello and welcome to another article from the <em>Meet Git</em> series.</p><p>In the previous article¹, I was showing you how to go through Git initial setup. Today, as we’re good to go, we can finally do something cool, for example… <strong>write a cookbook</strong>.</p><p>Why cookbook? Well, I was hungry when I started thinking about making this series.</p><p>More serious, I could’ve written yet another article with some snippets of source code, but the thing is, as I mentioned in <em>Meet Git #1</em>, I wanted to go a little beyond of programming, and demonstrate you that version control systems (for example Git) are also fantastic tools in other fields apart from computer science.</p><p>Let’s get started!</p><h3>Prerequisites</h3><ul><li>Git installed¹ and configured² on your computer (if you haven’t read my previous articles yet, check them out!)</li><li>A pinch of imagination, as we’re going to create a royal breakfast!</li></ul><h3>Use case: Creating a cookbook using Git</h3><p>The general idea is to write a few recipes, experiment with them, and let Git manage all changes that we’ll be applying to our cookbook.</p><p>Oh, one more thing: we’re going to write down our recipes in the plain <em>.txt </em>format, so forget about LibreOffice Writer or Microsoft Word.</p><h4>Why to write a cookbook in the .txt file?</h4><p>I know, real cookbooks, like other books, are more complex than just a plain text.</p><p>Most often (if not always), books contain chapter names, paragraphs, sidenotes, and other sections stylized differently than a regular text. Even the content of the chapters itself has parameters, such as the appropriate size and type of font.</p><p><strong>Because we’ll be writing down the recipe in the .txt file, we won’t be able to use the above attributes. </strong>You may think of it as a limitation, but in my opinion this approach has significant advantages:</p><ul><li>Foremost, I want to show you how Git operates on simple text files, as Git really excels at it.</li><li><strong>Once you understand the basics of Git, it’ll be much easier for you to understand why .doc, .docx and other common text formats are so special for Git (and why they’re tricky in terms of tracking changes)</strong></li><li>Then you’ll be able to pick the right decision on how and what to store in Git repository</li></ul><p>You may ask: <em>Does this mean that I can use Git solely for keeping history of plain .txt files?</em></p><p>My answer is: <em>Not at all, but you need to be aware of certain pitfalls.</em></p><p>For now, let’s just stick to the .txt format, and in the next articles we’ll be upgrading our cookbook. At some point, we will consider whether there is a more suitable text format to represent the cookbook.</p><h3>Writing the first recipe</h3><h4>Create a git repository</h4><p>Okay, I already got hungry, so there’s no time for theory.</p><p>First, we need to choose the directory where we’ll be working on our first recipe <strong>(this location will also be our Git repository)</strong>. Open Git Bash or your favorite terminal, and go to the directory of your choice. In my case, I chose the Documents directory of my Windows user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*T0vIbigvDZLUakgg3vu6wg.png" /><figcaption>I’m going to the Documents directory</figcaption></figure><p>If you’re using Git Bash, there’s a high chance that Git Bash has started in the user’s home directory. How to know that? The ~ character stands for the user’s directory.</p><p>Here’s a short cheat sheet how to navigate in command line:</p><ul><li>If you want to know where exactly you are, enter pwd, and you’ll see the absolute path to your current directory</li><li>To list the content of the current directory, enter ls command</li><li>To change the current directory, use cd command followed by the path you want to go to (if you are not comfortable navigating directories from the command line, you can find great tutorials on the Web, like this one³)</li></ul><p>Alright, let’s create an empty repository. Enter git init cookbook, and this will tell Git to create a new subdirectory called cookbook:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*1X7u3N5mc7ioljjFyOmxhQ.png" /><figcaption>An empty repository created by Git</figcaption></figure><p>You may wonder why you couldn’t just create this directory manually. <strong>As a reminder: a Git repository is a directory that contains a hidden </strong><strong>.git directory inside.</strong> By entering git init command, Git did all the magic and prepared its .git directory accordingly.</p><h4>About the status of Git repository</h4><p>If you’re using Git Bash and you see the blue text saying master or main, you can be sure you are inside the Git repository. On the other hand, <strong>if you’re using a terminal on Linux, you may not see the current branch by default.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*uqXW061PLV4LcZvHrBtm-A.png" /><figcaption>Git Bash shows the current branch</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*-JQ6aDYHjS9-9NFSOuO-6Q.png" /><figcaption>By default, Linux terminals don’t show Git-related information</figcaption></figure><p>Generally speaking, master and main are names of default <em>branches</em> in Git, but you don’t need to know what branch is at this moment.</p><p>The first operation we can perform is to check the repository status. Your repository is supposed to be empty — entergit status, and you should see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*FZsnHZYXvTsXw8DcFLsmpg.png" /><figcaption>Git saying the cookbook repository is empty</figcaption></figure><h4>Write the recipe</h4><p>It’s time to write the recipe for our Royal Breakfast! Create a new file called royal_breakfast.txtin the cookbook directory, and write the following:</p><blockquote>Ingredients:</blockquote><blockquote>- 1 roll</blockquote><blockquote>- cream cheese</blockquote><blockquote>- sprouts</blockquote><blockquote>Preparation:</blockquote><blockquote>Cut the roll in half, spread cream cheese on the roll and lay out the sprouts.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*iv7xztYfjRNL8si7KAA1uQ.png" /><figcaption>Write the recipe in your favorite text editor</figcaption></figure><h4>Check the status of your repository</h4><p>Once you saved the file, enter git status in terminal, and you’ll notice that Git found your recipe, but the file is not tracked by Git yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*VYD1uSOXhB22xQ-6UC3HZw.png" /><figcaption>Git has noticed the new file, but it doesn’t track it yet</figcaption></figure><h4>Select your file for next commit</h4><p>To make Git track your recipe, enter git add royal_breakfast.txt, which will add the recipe to the <em>staging area</em>. By marking files as staged, you’re instructing Git which changes you want to store in the next snapshot (during the next commit).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*xC2C6odEps7SyeSgD98p_Q.png" /><figcaption>We told Git to select our recipe for next commit</figcaption></figure><h4>Tell Git to save your version of the recipe</h4><p>Eventually, we can tell Git to store our precious recipe. You have two options to do this:</p><ul><li>Enter git commit -m &quot;&lt;your_commit message&gt;&quot; (preferable method for short messages/one-liners)</li><li>Enter git commit, and then write the commit message in an opened text editor (preferable method for longer messages). Also, this option utilizes the text editor pointed in Git’s configuration²</li></ul><p>If you see an error message saying something about missing username or email address, see my previous article², where I explained how to configure these settings.</p><p>If you configured it properly, you should see the screen as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*IdUDw1EmS-0AYQ6crvAwiQ.png" /><figcaption>Creating a first commit in Git repository</figcaption></figure><p><strong>Congrats, you’ve just performed your first commit in Git!</strong> But what exactly does it mean?</p><p>Your <em>version</em> of the breakfast is now stored and maintained by Git, which means whenever you change the contents of the royal_breakfast.txt file, or you even delete this file, Git will notice this, and you can then either save (commit) the new version on top of the previous commit, or you can restore the file to the state represented by your last commit.</p><h4>Check the repository status after commit</h4><p>Optionally, you can check the repository status with git status after you committed the recipe. This time Git tells you there’s nothing to commit, and this is because when you performed the commit, the staging area has been emptied, so it’s ready for another round.</p><p>By another round, I mean:</p><ul><li>editing the recipe</li><li>staging changes (selecting what changes are going to be committed)</li><li>committing changes</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*P_8qhPl7x0AZd_z7wG02lg.png" /><figcaption>After commit, “git status” shows the staging area is clean and ready for next round</figcaption></figure><h4>Show the history of your recipe</h4><p>In certain situations, we would like to know <em>how</em> and <em>when</em> our project was changing. The answer for <em>when</em> is git log.</p><p>Every commit contains information such as:</p><ul><li>Author (Krystian Szpiczakowski)</li><li>Creation date (Thursday, October 27th 2022)</li><li>Message (Write a draft version of the Royal Breakfast)</li><li>SHA-1 checksum (1033ca3420…), where usually only first five characters matter</li></ul><p>The checksum is an ID of each commit, which is crucial during working with Git, but you’ll learn about it later on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*BLckHLvAjCbUrNUGVe5bsA.png" /><figcaption>“git log” shows the history of the repository</figcaption></figure><h3>What’s next?</h3><p>In the next episode, we will upgrade the Royal Breakfast to make it truly royal. Also, we’ll take a closer look at commits and how they relate to each other.</p><h3>References</h3><p>[1] Krystian Szpiczakowski, <em>Install Git and start using it like a Pro (Meet Git #2) </em><a href="https://medium.com/@kszpiczakowski/install-git-and-start-using-it-like-a-pro-meet-git-2-b3c2dd96942f">https://medium.com/@kszpiczakowski/install-git-and-start-using-it-like-a-pro-meet-git-2-b3c2dd96942f</a></p><p>[2] Krystian Szpiczakowski, <em>Configure Git like a Pro (Meet Git #3)</em> <a href="https://medium.com/@kszpiczakowski/configure-git-like-a-pro-meet-git-3-e48f82b1c346">https://medium.com/@kszpiczakowski/configure-git-like-a-pro-meet-git-3-e48f82b1c346</a></p><p>[3] Marshall Gunner, <em>How to Change Directories in Command Prompt on Windows 10</em> <a href="https://www.howtogeek.com/659411/how-to-change-directories-in-command-prompt-on-windows-10/">https://www.howtogeek.com/659411/how-to-change-directories-in-command-prompt-on-windows-10/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a286e4e08109" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/how-to-start-cooking-with-git-meet-git-4-a286e4e08109">How to start cooking with Git (Meet Git #4)</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configure Git like a Pro (Meet Git #3)]]></title>
            <link>https://medium.com/@kszpiczakowski/configure-git-like-a-pro-meet-git-3-e48f82b1c346?source=rss-2f645dc7423c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e48f82b1c346</guid>
            <category><![CDATA[backup]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Krystian Szpiczakowski]]></dc:creator>
            <pubDate>Thu, 13 Oct 2022 15:17:50 GMT</pubDate>
            <atom:updated>2022-10-25T05:52:53.892Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction to git configuration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ggk4Xe-s_qz5M25j" /><figcaption>Photo by <a href="https://unsplash.com/@6heinz3r?utm_source=medium&amp;utm_medium=referral">Gabriel Heinzer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hello and welcome to the next episode of my Git series, devoted not necessarily developers.</p><p>Previously¹, I was showing you how to install Git step by step on your computer. Today, I’m going to do a brief introduction to Git configuration.</p><h3>Why to configure?</h3><p>You may wonder what to configure, as you may not know how Git works at all. If that’s the case, don’t worry, because I will show you today only the absolute minimum that is required to kick off.</p><p>Git can be configured in many ways for many reasons, for instance:</p><ul><li>Choose a default editor for writing commit messages</li><li>Instruct Git how to deal with line endings (Windows and Linux operating systems treat line endings differently, which will be explained in one of the next articles)</li><li>If you execute the same Git commands over and over again, it might be helpful to speed up your work by creating <em>aliases</em></li><li>And much more, which I’ll be explaining in subsequent articles</li></ul><h3>Scopes of configuration</h3><p>Before we move on, you need to know there are three scopes of configuration: <strong>system</strong>, <strong>global </strong>and <strong>local (project) </strong>settings.</p><h4>System settings</h4><p>System settings are on top of the hierarchy, and simply put, those are applied for all users/accounts and their Git repositories on the operating system.</p><p><strong>If you installed Git on Windows</strong> in the default directory, then system settings should be present under the following path: C:\Program Files\Git\etc\gitconfig.</p><p><strong>For Linux</strong>, system settings are stored in the following file: /etc/gitconfig.</p><p>To check current system settings, open Git Bash or terminal, and enter git config --list --system.</p><p>To set a system property, use git config --system &lt;property&gt; &lt;value&gt;, for instance git config --system core.autocrlf true.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*rJXZoy4Oj9RJatFEOLg-tw.png" /><figcaption>System-scoped Git configuration</figcaption></figure><h4>Global settings</h4><p>Global settings are one level below compared to system settings, and they apply to the current user/account on your operating system.</p><p>Those settings are stored in the user’s directory:</p><ul><li>On Windows: C:\Users\&lt;user&gt;\.gitconfig</li><li>On Linux: /home/&lt;user&gt;/.gitconfig</li></ul><p>Global settings have a lower scope than system settings, and this allows you to overwrite settings coming from the system scope.</p><p>For example, if the system property core.editor has value vim, this means that all users in the operating system will use Vim as the default text editor for Git. Then, if we set a value nano for the same property core.editor, but within the global scope, the effective value of this setting will be nano. This means, that the default editor for your account is Nano instead of Vim.</p><p>To check current global settings, enter the following command in the terminal:git config --list --global.</p><p>To set a global property, use git config --global &lt;property&gt; &lt;value&gt;, for instance git config --global core.editor nano.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*20Yr5g1qE-OQj2kDcEfchA.png" /><figcaption>Vim is the default text editor in the system scope</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*Io5lIJrBWgLcdIjnB-82hw.png" /><figcaption>Nano is the default text editor in the global scope (for the current user of the operating system)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*CpaxnBtdNYxU1Gr1VhpQyw.png" /><figcaption>Nano has been automatically launched when “git commit” executed</figcaption></figure><h4>Project settings</h4><p>Project/local scope is the lowest scope managed by Git. This means, any settings existing in the higher scopes (system and global), will be overwritten by the same property from the project scope.</p><p>Project settings are stored in a configuration file, under &lt;git_repo&gt;/.git/config, where git_repo is just a directory containing a .git subdirectory generated by Git (this will be covered in the next article).</p><p>To check current local settings, enter the following command in the terminal:git config --list --local.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*6nnT1EgLztzmWm_u9x45Jg.png" /><figcaption>Local configuration is stored within Git repository</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*cEH-xztuf0IsgqtKVW8C0w.png" /><figcaption>Local-scoped Git configuration</figcaption></figure><p>Changing local configuration may be useful if you work on multiple repositories, and say, for one of them you’d like to use a different e-mail address.</p><p>To adjust the local-scoped configuration, use git config --local &lt;property&gt; &lt;value&gt;, for example git config --local user.email example@example.com. Also, you can skip the --local flag, so git config user.email example@example.com has the same effect.</p><h4>If you don’t know where the setting comes from</h4><p>As you can imagine, three different scopes of configuration can sometimes become a mess. If you got lost, and you’d like to investigate what’s really going on, you have two options:</p><ul><li>git config --list --show-origin</li><li>git config --list --show-scope</li></ul><p>The two commands are similar: the first shows next to each setting the location from which Git reads the configuration, and the second shows the scope for the given setting. <strong>This is extremely useful, especially if you wonder why Git behaves differently than you expect.</strong></p><p>It happened to me that Git was behaving weird, and only after executing git config --list --show-origin did I understand the reason — part of my configuration was derived from the system-scoped configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*X2maONmSmyOzhckLNft0OA.png" /><figcaption>Show origin of each setting in Git configuration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*m60JOxApdIqvVGc70CMQUA.png" /><figcaption>Show scope of each setting in Git configuration</figcaption></figure><h3>Initial configuration</h3><p>Initial Git setup is very simple, and it boils down to checking the following:</p><ul><li>Choose how Git is supposed to treat line endings</li><li>Specify username and e-mail address (this information will be included in your commits)</li><li>Select a default text editor</li></ul><h4>Setting #1: Handle line endings</h4><p>If you have a fresh installation of Git, this setting should be already configured, regardless if you’re using Windows, Linux or Mac. Nonetheless, it’s very important to double-check if the correct value is present, because this value determines how Git will treat line endings in within text files.</p><p>Briefly, Windows uses CRLF line ending, while Linux and macOS use LF line ending, but this is a story for a separate article.</p><p>Depending on the operating system you are using:</p><ul><li>For Windows, you must ensure that core.autocrlf is set to true</li><li>For Linux/macOS, you must ensure that core.autocrlf is set to input</li></ul><p>In case you have invalid setting, just fix the configuration with git config, as explained earlier.</p><p>*If you are already familiar with Git, you may say this issue could (and should) be solved by editing the .gitattributes file — that’s correct, but this article is already packed with information, so I don’t want beginners to bother with another topic. I’ll come back to this one — I promise :)</p><h4>Setting #2: Add username and email</h4><p>This is a mandatory setting, which you must provide to start using Git. You don’t have to provide real information, generally speaking, but your username and e-mail will be included in every commit you perform. If you’re about to share your repository later on to collaborate with someone, providing real information may be useful.</p><p>To do this, enter these two commands:</p><ul><li>git config --global user.name &lt;your_name&gt;</li><li>git config --global user.email &lt;your_email&gt;</li></ul><h4>Setting #3: Select a default editor</h4><p>If you leave this setting, there’s a high likelihood that your default text editor is Vim. Some people like this tool, other hate it.</p><p>Well, the truth is that if you’ve never used Vim before, you’re going to curse because all common operations are not what you’re used to.</p><p>If you are adventurous, and you love learning (like me), go for Vim! For those who just want a simple text editor that doesn’t require additional learning, I can recommend Nano.</p><p>To set the editor, enter the following:</p><ul><li>git config --global core.editor vim for Vim</li><li>git config --global core.editor nano for Nano</li><li>git config --global core.editor &lt;path_to_your_editor&gt; for something else</li></ul><h3>Summary</h3><p>Use git config command in your terminal to manage Git-related settings on your computer:</p><ul><li>To list <strong>all </strong>properties: git config --list</li><li>To list <strong>system </strong>properties: git config --list --system</li><li>To list <strong>global </strong>properties: git config --list --global</li><li>To list <strong>local </strong>(repository) properties: git config --list --local</li><li>To set a <strong>system </strong>property: git config --system &lt;someproperty&gt; &lt;value&gt;</li><li>To set a <strong>global </strong>property: git config --global &lt;someproperty&gt; &lt;value&gt;</li><li>To set a <strong>local </strong>(repository) property: git config --local &lt;someproperty&gt; &lt;value&gt;, or you can skip the --local flag</li></ul><p>Additionally, if you want to know an explicit config location and scope, use the following:</p><ul><li>To show where the setting comes from:git config --list --show-origin</li><li>To show to which scope the particular setting belongs: git config --list --show-scope</li></ul><h3>What’s next?</h3><p>Congrats! You’ve just learned how to configure Git, so you’re ready to start using Git for real!</p><p>To be honest, I expected this article to be shorter. On the other hand, the configuration described above is the absolute minimum to start using Git, and if you’d like to learn more about Git configuration, check out the configuration chapter in an excellent book titled <em>Pro Git²</em>.</p><p>In the next article, we will create our first Git repository and finally start doing practical stuff, so stay tuned!</p><h3>References</h3><p>[1] Krystian Szpiczakowski, <em>Install Git and start using it like a Pro (Meet Git #2) </em><a href="https://medium.com/@kszpiczakowski/install-git-and-start-using-it-like-a-pro-meet-git-2-b3c2dd96942f">https://medium.com/@kszpiczakowski/install-git-and-start-using-it-like-a-pro-meet-git-2-b3c2dd96942f</a></p><p>[2] Chacon, S &amp; Straub, B 2014, <em>Pro Git</em>, <a href="https://git-scm.com/book/en/v2">https://git-scm.com/book/en/v2</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e48f82b1c346" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Install Git and start using it like a Pro (Meet Git #2)]]></title>
            <link>https://medium.com/@kszpiczakowski/install-git-and-start-using-it-like-a-pro-meet-git-2-b3c2dd96942f?source=rss-2f645dc7423c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3c2dd96942f</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Krystian Szpiczakowski]]></dc:creator>
            <pubDate>Fri, 07 Oct 2022 20:19:29 GMT</pubDate>
            <atom:updated>2022-10-25T05:36:40.058Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to install Git step by step</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lpIkrcJxgLkptRqa" /><figcaption>Photo by <a href="https://unsplash.com/@linusmimietz?utm_source=medium&amp;utm_medium=referral">Linus Mimietz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the previous article¹, we were considering Git as a tool that can be successfully used in areas other than software development. If you missed that article, or you don’t know what Git is, I encourage you to check it out.</p><p>Today I’m going to show you how to install Git, as it might not be that obvious, especially if you’re doing it for the first time.</p><h3>Get the installer</h3><p>Visit the official website² and click on the appropriate link, depending on whether you are using Windows, Linux or Mac.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*RwqhbXPLZo6oAF1bZoU3SQ.png" /><figcaption>Git official website with available installers</figcaption></figure><h3>Install Git for Windows</h3><p>On Windows, to get started with Git, you can:</p><ul><li>Install Git from a downloaded installer</li><li>Use a portable version that doesn’t require installation</li><li>Install Git by using winget, which is a command-line tool (this won’t be covered in this article, however)</li></ul><p><strong>The latter is especially useful when you have a Windows account with limited permissions</strong>, and you can’t install software on your own (a company laptop is a good example here).</p><p>Given you want to install Git, get the installer, run it, and follow the instructions on the screen. <strong>Essentially, keep default settings on most screens, with a few exceptions. I will cover these exceptions in next paragraphs.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*_jD3Gtcxq1ohknR6_btV0Q.png" /><figcaption>Standalone and portable versions of Git for Windows</figcaption></figure><h4>Bash profile for Windows Terminal</h4><p>On the screen with the selection of components, I would also recommend selecting <em>“Add a Git Bash Profile to Windows Terminal”.</em></p><p>This option may be useful, if your Windows comes with <strong>Windows Terminal</strong>. If you don’t have it, you can install this tool from Microsoft Store, but this is completely up to you. Keep in mind that Git comes with its own command line, called <strong><em>Git Bash</em></strong>, so you’ll be able to use Git even if you omit this checkbox.</p><p>Besides that, you can create a profile within Windows Terminal for Git Bash manually at any time, so don’t worry too much about this setting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*VrTJ0ybJwMJ9du2q6YBUHg.png" /><figcaption>During Git installation, you can integrate Git with Windows Terminal</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BvAubtr5KKBOLXFf26Xi4Q.png" /><figcaption>Windows Terminal available on Microsoft Store</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*28y64AaiNVOXgP0ncKWj6w.png" /><figcaption>Git installer can create a convenient profile in Windows Terminal</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*DdXJ_lHGd258LoYYVIWQQQ.png" /><figcaption>The default Git Bash for those who don’t use Windows Terminal</figcaption></figure><h4>Choosing the default text editor</h4><p>The next setting worth considering is a <strong>text editor associated with Git</strong>. Using Git requires writing some text, and because Git is not a text editor itself, we have to choose our favorite tool. <strong>The default Git’s text editor, <em>Vim</em>, is quite powerful, but it can give you a headache if this is your first contact with this editor. </strong>I remember myself boxing with Vim, because it turned out that even such a simple operation as closing the application is challenging enough for newcomers.</p><p>If you’re not tech-savvy, or you don’t want to spend your time to learn another tool, select the text editor you are familiar with. I personally stick to Vim, but it’s just a matter of taste, and you can change your choice at any time.</p><p>Basically, you can control this setting by changing a property managed by Git, named core.editor — I’ll show you how to change this and other settings in the next article, when we’ll be configuring Git for our first repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*y7R-SGHsubO_Zq2S4OZlIw.png" /><figcaption>By default, Vim is the text editor you will use along with Git</figcaption></figure><h4>Configuring the line endings</h4><p>Because Git is a tool that primarily operates on text files, Git wants to know how it is supposed to act on text files and their line endings.</p><p>If you’re installing Git on Windows, it’s most likely you want to keep the default setting <em>“Checkout Windows-style, commit Unix-style line endings”</em>.</p><p>Keep this setting as-is for now — I will explain the differences between these options in one of the next articles. This behavior can be configured at any time via the core.autocrlf property.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*jaCES5Bkn4Yc1SRuLz1UfQ.png" /><figcaption>The default line endings in Git for Windows</figcaption></figure><h4>Configuring extras</h4><p>The settings below are completely optional, and they don’t affect your workflow, but it’s worth to select them for better overall performance.</p><p>On the <em>“Configuring extra options”</em> and <em>“Configuring experimental options”</em> screens, select</p><ul><li><em>“Enable file system caching”</em> (the property stored in Git as core.fscache)</li><li><em>“Enable experimental built-in file system monitor”</em> (the property stored as core.fsmonitor)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*BwffhegRqumMuX1k6Qahmg.png" /><figcaption>Enable file system caching for a performance boost</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*ZNUyWdNSHmaoQQnADh9-Gw.png" /><figcaption>Enable built-in file system monitor to speed up Git operations</figcaption></figure><h4>When you’ve finally gone through the wizard…</h4><p>Click the <em>“Finish”</em> button,<em> </em>open <em>“Start”</em> menu, and search for <em>“Git Bash”</em>. If the installation was successful, you’ll see a command line as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*f5fKGYAr3Tm6J08e5FajKg.png" /><figcaption>At last! The Windows installer is a bit long, but it does a lot of setup for us.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*BWt4keMpchS1c_muxJUfMA.png" /><figcaption>On Windows, Git Bash can be found in the Start menu</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*Zv94BUCIcKlINag5bi9fTg.png" /><figcaption>This is how your command center looks like (Git Bash)</figcaption></figure><h3>Use Git Portable</h3><p>Like I wrote earlier, if you don’t want to (or you can’t) install the standalone version of Git, you can go for Git Portable.</p><p>To do so, follow these simple steps:</p><ul><li>Get the file with Git Portable (as of October 5, 2022, there is a .7z archive to download)</li><li>Extract the archive with a tool that supports .7z, like 7-zip³</li><li>Run git-bash.exe from the extracted directory</li><li>Voilà!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2F1RCefv67RnhN2PLhgOhQ.png" /><figcaption>You can extract the .7z archive containing Git Portable by using 7-zip</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fc0WELw34nnh_vDlqfqhqQ.png" /><figcaption>Once you extracted the archive, find the git-bash.exe binary and run it</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*Zv94BUCIcKlINag5bi9fTg.png" /><figcaption>Git Bash is now running</figcaption></figure><h3>Install Git on Linux</h3><p>Installation of Git on Linux is a much more straightforward process compared to Git for Windows, but this has also some drawbacks, i.e. you need to do additional configuration yourself.</p><p>In the next article, I’m going to explain how to configure Git when you don’t have such a fancy wizard as Windows users have.</p><h4>Git on Ubuntu</h4><p>In order to install Git on Ubuntu, perform these two steps:</p><ul><li>Open terminal</li><li>Type git --version, and if the message says something like <em>“Command ‘git’ not found”</em>, proceed to the next step</li><li>Type: sudo apt install git, and confirm by hitting y on your keyboard</li></ul><p>To verify that Git has been installed, type againgit --version — if everything is fine, this time you should see the version of installed Git.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*a1L-e97aVej3eqePa9iZIA.png" /><figcaption>Git installation on Ubuntu</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*c-VMQiUjjYAFSsOUalyfJg.png" /><figcaption>Git has been installed on Ubuntu</figcaption></figure><h4>Git on Fedora</h4><p>The installation process on Fedora is almost identical to the one on Ubuntu. The main difference is the package manager, i.e. Fedora comes with dnf, whereas Ubuntu uses apt.</p><p>Fedora is smart enough, so that when you type git --version in the terminal, and Git is not installed, you’ll be asked to install a suggested package containing Git. This is very convenient, and you just have to confirm the installation by hitting y on your keyboard.</p><p>Alternatively, you can type the full command, similarly as on Ubuntu: sudo dnf install git</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*GOlNQaR20qQYTZ48XBhnBg.png" /><figcaption>Fedora even suggests a package where Git can be found</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*sMv6Fmz2f9j_F6zpZAM8kg.png" /><figcaption>Git installed on Fedora</figcaption></figure><h3>Git on macOS</h3><p>In general, there are several ways to install Git on Mac, and the easiest way is to download the installer from this website⁴. Then, run the installer and follow the instructions on the screen.</p><h3>What’s next?</h3><p>Congratulations! You’ve just installed Git on your machine, and you’re almost ready to use it.</p><p>Wait, almost? Well, we need to learn how to check the initial configuration, and how to make some adjustments in settings. Fortunately, I’ll teach you all of this in the next part, so stay tuned!</p><h3>References</h3><p>[1] Krystian Szpiczakowski, <em>Program that will boost your productivity </em><a href="https://medium.com/@kszpiczakowski/program-that-will-boost-your-productivity-36f0f63935b1">https://medium.com/@kszpiczakowski/program-that-will-boost-your-productivity-36f0f63935b1</a></p><p>[2] Git official website, <a href="https://git-scm.com/downloads">https://git-scm.com/downloads</a></p><p>[3] 7-zip official website, <a href="https://7-zip.org/">https://7-zip.org/</a></p><p>[4] Git installer for Mac, <a href="https://sourceforge.net/projects/git-osx-installer/files/">https://sourceforge.net/projects/git-osx-installer/files/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3c2dd96942f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Program that will boost your productivity (Meet Git #1)]]></title>
            <link>https://medium.com/@kszpiczakowski/program-that-will-boost-your-productivity-36f0f63935b1?source=rss-2f645dc7423c------2</link>
            <guid isPermaLink="false">https://medium.com/p/36f0f63935b1</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[computers]]></category>
            <dc:creator><![CDATA[Krystian Szpiczakowski]]></dc:creator>
            <pubDate>Thu, 22 Sep 2022 15:02:00 GMT</pubDate>
            <atom:updated>2022-10-02T10:04:45.452Z</atom:updated>
            <content:encoded><![CDATA[<h4>Use Git to back up your important stuff (and much more)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HDdfpizN5ROKqCac" /><figcaption>Photo by <a href="https://unsplash.com/@mailchimp?utm_source=medium&amp;utm_medium=referral">Mailchimp</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hello and welcome to the new article on my blog. Today, as usual, we’ll be looking at the topic related to IT, and the guest of today’s episode is a well-known version control system, <em>Git</em>.</p><p>Today’s episode will be a bit different, though. I’m going to go a little beyond computer science and programming, and <strong>demonstrate how using Git can help people outside the software development world</strong>.</p><p>I found out myself that some of the file management issues in non-IT projects can have a lot in common with problems that arise while writing the source code.</p><h3>Take control of your backups</h3><p>Do you recall a situation when you were working on some important document or project, and you periodically backed it up? At one point, your directory might have looked something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GnkNqz4DUC3c3ZwXDCXgDw.png" /><figcaption>Managing project files without Git can be a daunting challenge</figcaption></figure><p>Of course, this approach may be enough for very simple cases, but if you keep creating more copies this way, you can get lost eventually, and mistakenly use, or delete a wrong file.</p><p>What if I told you that <strong>developers have been using a free tool for solving these and other problems for years?</strong></p><h3>What is Git?</h3><p>If you’re a developer, there’s a high chance you are pretty much familiar with Git, or at least you have heard of it.</p><p>If you do not come from the IT industry, this tool may be completely unknown to you, however. Even though, don’t you worry! This tool is quite straightforward to use for basic use cases, what you’ll learn from this and next articles.</p><p>Let’s check the definition found on the Git official website¹:</p><blockquote>Git is a free and open source <strong>distributed version control system</strong> designed to handle everything from small to very large projects with speed and efficiency.</blockquote><h4>Version Control System? VCS? WTF?</h4><p>The idea behind this sophisticated term is not that difficult, as it might seem at a glance.</p><p>In a nutshell:</p><ul><li>Git lets you turn any folder into some kind of container (so-called <em>Git repository</em>) that can safely back up data inside this folder and its subdirectories</li><li>Your data can be stored locally (on your computer), and remotely (somewhere on a server), where the remote repository is optional</li><li>Any changes made within your repository, like adding/changing/deleting files, can be <em>tracked</em> by Git</li><li>By tracking, I mean Git recognizes when the contents of your directory changes, so that you can for instance tell Git to remember (<em>commit</em>) these changes</li><li>Every commit is a separate <em>version</em> of the repository, or in other words, those commits represents how your files change in time</li><li>Git allows you to compare commits with each other, so that you can, for example, check how you progressed with your project</li><li>If you want, you can go back and restore your files from <em>any</em> commit you’ve created</li></ul><h3>What is Git typically used for?</h3><p>Git has been in use since 2005, and it’s the most widely used version control system in IT projects. As an example, development teams (and not only) can do with Git the following:</p><ul><li>Back up source code</li><li>Collaborate on code with others</li><li>Travel in time :)</li><li>Track project progress as Git holds the entire history of how the code was changing</li><li>Restore project files from Git history if needed</li><li>Automating IT infrastructure (GitOps)</li></ul><h3>What else can Git be used for?</h3><p>As it turns out, non-IT people can experience similar problems, and in my opinion Git can be a lifesaver — see the examples below:</p><ul><li>You’re writing a document in MS Word or LibreOffice, and you’d like to have a series of backups of your progress, not limited only to the last time when you clicked <em>“Save” </em>button</li><li>You might want to keep subsequent versions of your document in one place, and not have a mess with dozens of copied copies of copies of the original file</li><li>Your program has unexpectedly saved your project (welcome, autosave feature), and you can’t easily bring the project to the desired state. With Git, you can restore your project easily</li><li>If you ran out of undo operation (Ctrl+Z), and you want to bring your project back, you can restore project files from Git history</li><li>You might also want to store your backup somewhere else</li><li>You would like to share your project with someone else, either only to view it, or also to collaborate</li></ul><h3>Get the best of Git and use it for your needs</h3><p>As you can see, Git can bring much value, but it has also some limitations, which you should know about.</p><p>One of the most important things, is <strong>Git has been primarily designed to work with text files</strong>, as this was a tool designed mainly for developers. It’s because source code is just a plain text, and indeed, <strong>working with text files is something that Git excels at.</strong></p><p>Of course, Git <em>can</em> also operate on binary files, i.e. graphics, images and other files that don’t have a textual representation, for example GIMP projects (these are files with <em>.xcf</em> extension). However, it comes with certain limitations, that will (or will not) affect your workflow.</p><h4>How do I personally use Git?</h4><p>I found out that Git helps me when I create graphics in GIMP, or when I edit videos using HitFilm. Backing up my projects is something really useful, especially while project’s complexity grows.</p><p>Although both programs use project files that are not text files (.xcf for GIMP, .hfp for HitFilm), I still find Git helpful for these uses. Okay, <em>.hfp </em>projects are text files, but their structure makes they are not meant to be read by humans.</p><h3>What’s next?</h3><p>For sure, Git is a powerful tool that is worth getting to know. If you are still curious, stay tuned as I’m going to show you in this series step-by-step how to use Git.</p><p>In the next article, I’m going to show you how to install Git, and start using it like a Pro.</p><h3>References</h3><p>[1] Git official website, <a href="https://git-scm.com/">https://git-scm.com/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36f0f63935b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>