<?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 sandoh on Medium]]></title>
        <description><![CDATA[Stories by sandoh on Medium]]></description>
        <link>https://medium.com/@pearlsandoh?source=rss-2e4af4face33------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mTrcW3-rrNyGu7_wIGNI9g.jpeg</url>
            <title>Stories by sandoh on Medium</title>
            <link>https://medium.com/@pearlsandoh?source=rss-2e4af4face33------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 17:42:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pearlsandoh/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[Two Piles, One Golden Ratio]]></title>
            <link>https://medium.com/@pearlsandoh/two-piles-one-golden-ratio-5ec045268e68?source=rss-2e4af4face33------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ec045268e68</guid>
            <category><![CDATA[game-theory]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[golden-ratio]]></category>
            <category><![CDATA[recreational-mathematics]]></category>
            <dc:creator><![CDATA[sandoh]]></dc:creator>
            <pubDate>Sat, 25 Jul 2026 01:07:02 GMT</pubDate>
            <atom:updated>2026-07-25T01:07:02.212Z</atom:updated>
            <content:encoded><![CDATA[<h4>What backward induction reveals about Wythoff’s Nim</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*72MEE87deakG_Z2M86hi9A.png" /><figcaption>Figure 1: One game, one golden ratio, zero coincidence. The image is AI generated.</figcaption></figure><p>Mathematics has a habit of surprising you when you least expect it. You sit down with what looks like a simple problem, you follow the logic wherever it goes, and somewhere along the way something beautiful appears that nobody told you to look for. Not because you went searching for it, but because it was already there, waiting.</p><p>I first encountered this feeling properly during my first week at AIMS. We played a game in class. Two numbers, two players, a simple rule for how to move. It looked like a toy problem. Something to warm up with but by the end of the class, the golden ratio had shown up uninvited.</p><p>The game is called Wythoff’s Nim and it works like this:</p><p>Two players start with a pair of non-negative integers, say <strong>(m, n)</strong>. On each turn, a player can do one of three things: subtract any positive integer from <strong>m</strong>, subtract any positive integer from <strong>n</strong>, or subtract the same positive integer from both <strong>m</strong> and <strong>n</strong> simultaneously. The only constraint is that you cannot subtract more than the number itself, that is you cannot subtract to get a negative number.</p><p>The player who reaches <strong>(0, 0)</strong> wins.</p><p>That is the entire ruleset. No hidden complexity, no special cases. Just two numbers and three possible moves.</p><p>The natural question is: given any starting position <strong>(m, n)</strong>, is there a winning strategy? And if so, what is it?</p><p>To answer that, we need to figure out which positions are winning positions, that is, positions from which, assuming optimal play, the player whose turn it is will always win.</p><p>The easiest place to start is <strong>(0, 0)</strong> itself. The player who reaches <strong>(0, 0)</strong> wins, so <strong>(0, 0)</strong> is a winning position by definition. From there, using a both trial and error together with backwards induction, we can determine some other winning positions.</p><p>Any position from which a player can move directly to <strong>(0, 0)</strong> is a losing position for the person who played it, because the next player will immediately win. It is easy to determine that those positions are <strong>(s, 0)</strong>, <strong>(0, s)</strong>, and <strong>(s, s)</strong> for any positive integer <strong>s</strong> since you can always subtract <strong>s</strong> from one side or both sides and land on <strong>(0, 0)</strong>.</p><p>So the first winning position is <strong>(0, 0)</strong>, and everything of the form <strong>(s, 0)</strong>, <strong>(0, s)</strong>, or <strong>(s, s)</strong> is a losing position for the player who just played.</p><p>Now we look for the next winning position. It has to be a position that cannot reach any previous winning position, in this case <strong>(0, 0)</strong>,<strong> </strong>in one move. The smallest candidate, after ruling out all the losing positions above, is (1, 2).</p><p>From (1, 2), every possible move leads to a losing position for the opponent as illustrated in the table below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*8-Ytreoj6GqM94bLgoA2PA.png" /><figcaption>Table 1: All possible moves from the position (1, 2) and their outcomes. Every move leads to a losing position for the opponent, confirming that (1, 2) is a winning position.</figcaption></figure><p>Continuing this way, we get the third winning position, then the fourth, and so on. The first ten winning positions turn out to be:</p><p>(0, 0), (1, 2), (3, 5), (4, 7), (6, 10), (8, 13), (9, 15), (11, 18), (12, 20), (14, 23)</p><p>Look at those numbers for a moment. Do you notice anything? Can you observe any patterns?</p><p>A few things jump out immediately.</p><p>First look at the differences between the pairs of numbers.</p><p>(0, 0): 0, (1, 2): 1, (3, 5): 2, (4, 7): 3 …</p><p>Keep going and the differences climb one at a time, 0 through 9, in order, no gaps, no repeats.</p><p>Second, notice how each pair is actually built. The smaller number is simply the next nonnegative integer that has not yet been used. The larger number is that same integer plus the next difference in line. Starting from (0, 0), the next unused integer is 1, and the next difference is 1, giving (1, 2) as the next winning position. From (1, 2), the next unused integer is 3, and the next difference is 2, giving (3, 5). Following this rule generates the rest of the list.</p><p>By hand, this is manageable for ten pairs. It quickly becomes tedious for a hundred. The rule already found, take the next unused integer, then add the next difference, turns directly into the following code.</p><pre>def win_pos(n):<br>    positions = [(0, 0)]<br>    used_ints = {0}<br>    for common_diff in range(1, n):<br>        m = 0<br>        while m in used_ints:<br>            m += 1<br>        y = m + common_diff<br>        used_ints.add(m)<br>        used_ints.add(y)<br>        positions.append((m, y))<br>    return positions</pre><p>Calling win_pos(10) reproduces the same ten pairs found by hand. Calling win_pos(100) generates a hundred of them in a fraction of a second, far more than anyone would want to compute by hand, and exactly enough to see what these positions actually look like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*FldzCAr_yDu2Tc2Irovqrg.png" /><figcaption>Figure 3: Plot of winning positions (m, n) in blue and their mirror image (n, m) in orange.</figcaption></figure><p>Another less obvious pattern appears in the geometry of the points. If we step back and treat each winning pair simply as a point in the plane, something subtle begins to happen: the sequence stops looking like a list of isolated points and starts behaving like it is tracing a direction, slowly aligning itself along a line.</p><p>A natural question to ask about these alignments is what their slope might be. Since these winning positions do not form a continuous line, we cannot compute a slope in the usual geometric sense from any fixed pair of points. Instead, we compare pairs of points at increasing scales and examine how the ratio between their coordinates behaves as the sequence grows.</p><p>Plotting the ratio n/m for each winning position, and skipping (0, 0) to avoid dividing by zero, we notice something almost immediately. (1, 2) gives a ratio of 2. (3, 5) gives 1.667. (4, 7) gives 1.75. (6, 10) gives 1.667 again. (8, 13) gives 1.625. (11, 18) gives 1.636. (12, 20) gives 1.667. (14, 23) gives 1.643.</p><p>At first glance, these numbers look almost arbitrary, jumping up, dropping back down, never quite settling. But look again, and they are all hovering in a tight band, never straying far from something close to 1.618. That is not an accident of these particular ten points. It is a consequence of a fact we have already established in Figure 3, which is that the winning positions themselves lie on a straight line. And since a line is completely determined by its slope, we can find that slope directly using a linear fit:</p><pre>slope, intercept = np.polyfit(x, y, 1)</pre><p>This returns 1.6180499523215728, matching φ = (1 + √v 5)/2 to the first several digits.</p><p>This is the piece that ties the wobbling ratios back together. The quantity n/m for any individual winning position is just the slope of the line connecting that single point to the origin. Because all the winning positions sit on (or extremely close to) one common line through the origin, the slope from the origin to any of them should, in principle, agree with the slope of the line itself. The small differences we saw in the early ratios, 2, then 1.667, then 1.75, are simply the effect of measuring the slope to individual points before the pattern has had enough room to settle down; the underlying line, fit across all 100 points at once, is unambiguous, and its slope is φ.</p><p>So the wobble in the pointwise ratios was never really randomness. It was a handful of individual measurements of the slope of a line whose true value, computed properly across the whole dataset, is the golden ratio itself.</p><p>Now that we know where the winning positions actually sit, we can describe a genuine winning strategy for any position on the board, not just recognize a winning position when we see one, but know exactly what to do with a losing one.</p><p>Take any position (m, n), with m ≤ n without loss of generality (if m &gt; n, just swap them mentally, since the game treats both piles symmetrically). Compute the ratio n/m and compare it to the golden ratio, φ. There are exactly three possibilities:</p><p>If n/m &gt; φ, the position sits above the winning line. There are too many tokens on the right relative to the left.</p><p>If n/m &lt; 1/φ, the position sits below the winning line. There are too many tokens on the left relative to the right.</p><p>If 1/φ &lt; n/m &lt; φ, the position sits between the two lines, neither pile is far enough out of balance to fix with a single-sided move.</p><p>Each of these three cases points to a different kind of move, and this is really the heart of the strategy. If you’re above the line (too much on the right), subtract from the right side only, moving straight down until you land on a winning position. If you’re below the line (too much on the left), subtract from the left side only, moving straight across until you land on a winning position. And if you’re caught in between, no single-sided subtraction will do it, you subtract the same amount from both piles at once, moving diagonally toward the winning line until you land exactly on it.</p><p>In every one of these three cases, a winning position is always reachable in one move. That is precisely what makes the losing positions losing, whatever position your opponent leaves you in, if it isn’t already a winning position itself, one of these three moves gets you to one. And once you’re on a winning position, the roles reverse: any move your opponent makes will necessarily knock them off the line, back into one of the three categories, handing the advantage straight back to you.</p><p>So the entire game, for all its apparent freedom (subtract anything, from either pile, or both), collapses into a single geometric fact. There is one line through the origin with slope φ, one with slope 1/φ, and everything about how to play well is just a question of which side of those two lines you’re standing on.</p><p>I first sat with this problem as a warm-up exercise, something to loosen up the room before the real content of the course began. It did not stay a warm-up for long. What started as trial and error on paper, checking which small pairs of numbers led where, turned out to have a straight line hiding underneath it, and that line turned out to have a slope that shows up in sunflower heads and nautilus shells and Renaissance paintings. Nobody built the golden ratio into the rules of Wythoff’s Nim. It was already there, in the only number that could make the bookkeeping of the game consistent with itself, waiting for anyone patient enough to subtract their way toward it.</p><p>That, I think, is the real lesson of that first week at AIMS. Mathematics doesn’t always announce when something beautiful is about to happen. Sometimes you just follow a simple rule as far as it goes, and it’s already there, waiting.</p><p>Before working through this on my own, I first came across Wythoff’s Nim through a video by <a href="https://www.youtube.com/@mostly_mental">Mostly Mental</a> on YouTube, which walks through the same game and its connection to the golden ratio. It’s worth watching alongside this piece, especially if you’d like to see the pattern discovered a second way, watching someone else follow the same rabbit hole is often more illuminating than reading about it after the fact.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FH7OS1pgATIY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DH7OS1pgATIY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FH7OS1pgATIY%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/81028ad772491fb4f1f3bf76123161d0/href">https://medium.com/media/81028ad772491fb4f1f3bf76123161d0/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ec045268e68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Practical Approach to Denoising Sound]]></title>
            <link>https://medium.com/@pearlsandoh/a-practical-approach-to-denoising-sound-5422beebeb74?source=rss-2e4af4face33------2</link>
            <guid isPermaLink="false">https://medium.com/p/5422beebeb74</guid>
            <category><![CDATA[audio-signal-processing]]></category>
            <category><![CDATA[signal-processing]]></category>
            <dc:creator><![CDATA[sandoh]]></dc:creator>
            <pubDate>Tue, 16 Jun 2026 16:41:30 GMT</pubDate>
            <atom:updated>2026-06-16T18:17:25.045Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Using Fourier transforms to separate signal from noise</em></h4><p>If you have ever tried to record yourself for a YouTube video, a podcast, or a voice note you actually wanted to keep, you know the problem. You hit record, you say what you want to say, you play it back. And underneath your voice, there it is: the hum of the fan, the street outside, someone’s music bleeding through the wall. The recording is ruined, and no amount of re-recording seems to fix it because the noise was always there. You just did not notice it until the microphone did.</p><p>This was the kind of situation I found myself in at AIMS Rwanda, one evening when our Signal Processing lecturer, Professor Paul Taylor of the National Institute of Mental Health, played us a recording of lions. Real lions, recorded in the field, buried under background noise. The assignment was simple: clean it up. No audio software. Just mathematics. It was one of those rare moments where mathematics stopped feeling abstract. I was not solving for x. I was listening to the difference between before and after, and the difference was audible.</p><p>This article is about how that works, what the mathematics actually says, why it gives you a way to separate sound from noise, and what the Fourier transform has to do with any of it.</p><p>Think about what sound actually is. When a lion roars, it disturbs the air around it. That disturbance travels outward, reaches your ears, and you hear something. A microphone does the same thing your ear does: it picks up those disturbances and records how strong they are at each moment in time.</p><p>Plot that and you get a waveform. Time on one axis, amplitude on the other.</p><p>Here is what the lions recording looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CPBhpu4S4grAy7L9skNiOA.png" /><figcaption>Figure 1: Waveform of the lions recording. The horizontal axis is time in seconds, the vertical axis is amplitude. The background cricket noise is visible throughout, even in the quieter moments between lion sounds.</figcaption></figure><p>You can already see something is wrong. Even in the quiet moments, the signal is not flat. There is always something there. That is the crickets, a background noise that never goes away.</p><p>The frustrating thing is that just looking at this picture, you cannot tell the lions apart from the crickets. They are all mixed together in the same plot, at the same time. To separate them, you need to stop thinking about time altogether.</p><p>This is the fundamental limitation of the time domain. When multiple sounds are recorded together, their amplitudes add up at every point in time. There is no way to untangle them without more information.</p><p>What you need is a way to ask a different question. Instead of asking “how loud is the signal at each moment in time,” you want to ask “what frequencies make up this signal, and how strong is each one?”</p><p>That is exactly what the Fourier transform does.</p><p>Every sound you have ever heard is made up of pure frequencies added together. The low hum of a fan is one frequency. The high pitch of a cricket is another. A lion’s roar is a combination of many. Even the most complex sound is just a sum of simpler ones, each with its own frequency and strength.</p><p>The Fourier transform takes your signal and asks: what are those frequencies, and how much of each one is present? Instead of plotting amplitude against time, it plots amplitude against frequency. That new plot is called the frequency spectrum.</p><p>Here is what the lions recording looks like in the frequency domain:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*asdTuzCLN_4eZT4eReZWjA.png" /><figcaption>Figure 2: Frequency spectrum of the lions recording, obtained by applying the Fourier transform. The horizontal axis is frequency in Hz, the vertical axis is magnitude (the absolute value of each frequency coefficient). The concentrated spikes near the centre correspond to the dominant frequency components in the recording.</figcaption></figure><p>Now that we can see the signal in the frequency domain, we can do something we could not do before: we can choose which frequencies to keep and which to remove.</p><p>The idea is simple. We create a filter, an array of the same length as our signal, filled with zeros everywhere except in the low frequency range, where we set it to 1. When we multiply our Fourier transform by this filter, only the frequencies we marked with a 1 survive. Everything else gets zeroed out.</p><p>This is called a low pass filter. It lets the low frequencies pass through and blocks the high ones.</p><p>In code, it looks like this:</p><pre>H = np.zeros(N)<br>H[0:N//30] = 1<br>C = X * H</pre><p>Here, X is the Fourier transform of our signal, the array of frequency coefficients behind Figure 2, one value for every frequency present in the recording. H is the filter, and C is the filtered result, still living in the frequency domain.</p><p>We are keeping only the first 1/30th of the frequency range. Everything beyond that gets set to zero.</p><p>The result, C, is our filtered signal, still in the frequency domain. The lion sounds, which are concentrated in the low frequencies, are largely preserved. The cricket noise, which was spread across the higher frequencies, is largely gone.</p><p>Now we need to bring it back to time.</p><p>To get back to something we can actually hear, we apply the inverse Fourier transform.</p><p>If the Fourier transform takes a signal from time to frequency, the inverse does the opposite: it takes a signal from frequency back to time. You give it the filtered frequency spectrum, and it reconstructs a waveform.</p><p>In code, this is one line:</p><pre>new_x = np.fft.ifft(C)</pre><p>What comes back is a new time series, a waveform that contains only the frequencies we chose to keep. Here is what the original and the cleaned signal look like side by side:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qzv3eHXiF3WeJuZ8lzcTog.png" /><figcaption>Figure 3: Raw signal (blue) and processed signal (orange) plotted together. The processed signal is visibly smoother, with the background noise reduced while the main lion sounds are preserved.</figcaption></figure><p>The difference is visible. The processed signal is smoother, the constant background activity reduced. What remains is closer to the lions alone.</p><p>But the real test is not visual. It is audible. When you play back the cleaned recording, you can actually hear the difference. The crickets are quieter. The lions are clearer.</p><p>That is the Fourier transform at work.</p><p>There is something satisfying about this that goes beyond the result.</p><p>You started with a recording that was ruined by noise. You could hear the problem but you could not see it, and you certainly could not fix it just by staring at the waveform. The noise and the signal were tangled together in time, and time gave you no way to separate them.</p><p>The Fourier transform gave you a different perspective. Not better data, just a different way of looking at the same data. And from that perspective, the solution became obvious.</p><p>This is what mathematics does at its best. It does not always give you new information. Sometimes it just gives you the right way to look at the information you already have.</p><p>The lions were always there. You just needed the right lens to find them.</p><p><strong>Audio source</strong><br> The lion recording used here comes from <a href="https://sound-effects.bbcrewind.co.uk/search?q=07062015">BBC Sound Effects</a> and is free for non-commercial use.</p><p>To follow along, download the file from that link and place it in audio/ (or whichever folder you&#39;re working from). Not for commercial use.</p><p>The jupyter notebook with the code can be found <a href="https://github.com/PearlPearl-Pearl/AIMS-SP/blob/master/inclass/wave_proc_mono_class.ipynb">here.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5422beebeb74" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started With Git and GitHub]]></title>
            <link>https://medium.com/@pearlsandoh/getting-started-with-git-and-github-9fcfcd9803e7?source=rss-2e4af4face33------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fcfcd9803e7</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[sandoh]]></dc:creator>
            <pubDate>Sun, 29 Sep 2024 00:38:08 GMT</pubDate>
            <atom:updated>2024-09-29T00:38:08.097Z</atom:updated>
            <content:encoded><![CDATA[<p>At some point early in your tech journey, you’re likely to hear about Git or GitHub, whether from watching tutorials or in conversations with fellow tech enthusiasts. While these tools are essential in the software development process, they can initially seem daunting, especially since many beginners often confuse Git and GitHub as being the same thing — I know I used to! 😅 This article aims to demystify Git and GitHub, helping beginners understand and use them effectively for their needs, improving their development workflow and collaboration with other developers.</p><p>I’m sure by now you’ve inferred that Git and GitHub are not the same thing, so let’s start by explaining what each tool is and what it does. <strong>Git</strong> is a version control system. In simple terms, Git is a tool used to track changes to files and directories over time. Any changes you make to a file in your project can be tracked by Git, giving you complete control over which changes you want Git to track. On the other hand, <strong>GitHub</strong> is a platform that provides hosting for Git repositories (we’ll get to what these are later). While GitHub is widely used, other alternatives, like GitLab and Bitbucket, serve the same purpose. To summarize, Git is the tool for version control, while GitHub is a website for hosting Git repositories.</p><p>Now, let’s talk about <strong>repositories</strong> (or “repos” for short), as they play a crucial role in managing your project files. A repository is essentially a container that stores your project’s files, directories, and the changes made over time. You can choose which changes to track and which files or directories to store in the repository. When you ask Git to track a directory on your local machine, you’re essentially creating a local repository. You can later choose to host this repository on GitHub to enable easy collaboration and back up your project in case of device damage.</p><p>In Git, there are four main <strong>locations</strong> where your code can be found at any given time: the local working directory, the staging area, the local repository, and the remote repository. Understanding how code moves between these locations is fundamental to working with Git effectively.</p><ul><li>The <strong>local working directory</strong> is the folder on your computer where you store and actively edit all your code files. For instance, the directory where you’ve stored your Python or JavaScript files for a tutorial would be your local working directory.</li><li>The <strong>staging area</strong> is an intermediate space on your local machine where you gather the changes you want to commit (i.e., the changes you want Git to record). It’s useful because it allows you to control which changes Git will track. For example, if you modified both an index.html file and a style.css file, but only want Git to track the changes in style.css, the staging area enables you to do that.</li><li>When you <strong>commit</strong> your code (i.e., tell Git to record the changes you’ve staged), Git only records these changes locally in the <strong>local repository</strong>.</li><li>Lastly, the <strong>remote repository</strong> is a storage location (like GitHub) where you can host your code and changes, providing collaboration tools and backup in case your device gets damaged.</li></ul><p>Now that we’ve covered the concept of repositories and how code flows through these stages, let’s dive into how we can actually work with them. We’ll first walk through the essential commands used when creating a repository from scratch, followed by an overview of basic operations such as staging, committing, and pushing changes.</p><h4>Working with git repositories</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NsWKXNF_YQT4bsrvF_l6Zg.png" /><figcaption>Click on the dropdown to create a new repository</figcaption></figure><p>Typically, when starting a project, the first step is creating a remote repository on GitHub and then connecting it to a local repository on your machine. (You can also create the local repository first and then link it to GitHub). Let’s walk through this process:</p><ol><li><strong>Log in</strong> to your GitHub account.</li><li>Click the <strong>+ icon</strong> at the top of the page and select <strong>New repository</strong>.</li><li>Enter a name for your repo (ideally, the same name as your working directory) and click <strong>Create repository</strong>.</li><li>A new page will appear, giving you instructions on how to connect your newly created GitHub repo to your local repository. Copy the set of commands under the section titled <strong>…or create a new repository on the command line</strong>.</li></ol><p>Now, let’s break down these commands step-by-step so you fully understand what each one does:</p><ol><li><strong>echo &quot;# trial&quot; &gt;&gt; README.md</strong><br>This command stores the string # trial in the README.md file. If the file doesn’t already exist, Git will create it.</li><li><strong>git init</strong><br>This command initializes a new local repository in your current working directory. After running this command, you can verify the repository creation by running ls -a in your terminal and looking for the .git folder.</li><li><strong>git add README.md</strong><br>The git add command adds the README.md file to the staging area, preparing it for the next commit. If you want to add all files in your working directory, you can use git add ..</li><li><strong>git commit -m &quot;first commit&quot;</strong><br>The git commit command saves your staged changes to your local repository. The -m flag allows you to specify a commit message.</li><li><strong>git branch -M main</strong><br>This command renames the current branch to main. The -M flag forces Git to rename the branch, even if a branch named main already exists.</li><li><strong>git remote add origin https://github.com/YourUsername/YourRepository.git</strong><br>This command connects your local repository to the remote repository on GitHub.</li><li><strong>git push -u origin main</strong><br>Finally, this command pushes the changes in your local repository to the remote repository on GitHub. The -u flag sets the main branch on the remote repository as the upstream for future changes. After setting up the upstream on the initial push, you only need to run git push to push your changes to the same branch (Changing branches means you have to set a new upstream).</li></ol><p>By following these steps, you’ve successfully created a repository from scratch and pushed your code to GitHub. Now you’re ready to start using Git and GitHub to manage your projects and collaborate with others.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fcfcd9803e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>