<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Beşir Can BARUTÇU</title>
    <description>The latest articles on DEV Community by Beşir Can BARUTÇU (@beir_canbarutu_6125e74).</description>
    <link>https://dev.to/beir_canbarutu_6125e74</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3783084%2F0dda5864-df0f-4e25-adac-5bccade2aa31.png</url>
      <title>DEV Community: Beşir Can BARUTÇU</title>
      <link>https://dev.to/beir_canbarutu_6125e74</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/beir_canbarutu_6125e74"/>
    <language>en</language>
    <item>
      <title>Understanding Git Like a Graph</title>
      <dc:creator>Beşir Can BARUTÇU</dc:creator>
      <pubDate>Sun, 22 Feb 2026 21:52:35 +0000</pubDate>
      <link>https://dev.to/beir_canbarutu_6125e74/understanding-git-like-a-graph-58a</link>
      <guid>https://dev.to/beir_canbarutu_6125e74/understanding-git-like-a-graph-58a</guid>
      <description>&lt;h1&gt;
  
  
  Git is a Graph: Understanding the Logic
&lt;/h1&gt;

&lt;p&gt;Git is not just a list of commands; &lt;strong&gt;Git is a graph of commits&lt;/strong&gt;. If you understand the logic behind it, everything becomes simple. Git is a graph of commits.&lt;/p&gt;

&lt;h2&gt;
  
  
  Starting a Project
&lt;/h2&gt;

&lt;p&gt;There are two easy ways to do this:&lt;/p&gt;

&lt;h3&gt;
  
  
  1.Create a project folder from scratch:
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;git init&lt;/code&gt;&lt;br&gt;
This creates a new Git repository locally. Use this when starting a project from your desktop.&lt;/p&gt;
&lt;h3&gt;
  
  
  2.Clone an existing repository:
&lt;/h3&gt;

&lt;p&gt;If you want to download a ready-made repository and don't have a local folder yet, you can clone from GitHub.&lt;br&gt;
&lt;code&gt;cd Documents&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git clone https://github.com/user/project.git&lt;/code&gt;&lt;br&gt;
This connects your local project to the GitHub remote server automatically and creates a pointer called origin. (We will talk more about origin later).&lt;/p&gt;
&lt;h3&gt;
  
  
  What about Forking?
&lt;/h3&gt;

&lt;p&gt;Forking is a GitHub feature that copies someone else's repository to your own account. If you don’t have access to a repo but want to contribute, you fork it, then clone your fork locally. After writing code, you create a Pull Request (PR)—essentially saying, "Hey, I improved the code, what do you think?"&lt;/p&gt;
&lt;h2&gt;
  
  
  Daily Workflow &amp;amp; Teamwork
&lt;/h2&gt;

&lt;p&gt;When you work with a team, you want to save your progress and undo changes if things go bad. We use branches to keep work separated:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main *
└── dev
└── feature/task1 (You)
└── feature/task2 (Your teammate)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Working on feature/task1 means your changes won't affect your teammate’s code. Once you test your new features locally, you merge them into a shared codebase (like dev or main). You open a PR from your branch to dev, your teammates review it, and if it’s okay, it gets merged.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Daily Commands:
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;git branch&lt;/code&gt; (See all local branches)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git checkout dev&lt;/code&gt; (Switch to the dev branch)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git checkout -b feature/task&lt;/code&gt; (The -b stands for a new branch)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git add .&lt;/code&gt; (Track your file changes)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git commit -m "first commit"&lt;/code&gt; (Create a checkpoint)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git push -u origin dev&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;-u stands for upstream. it creates a connection from your local branch to the remote branch. After this, you can just write git push without typing the rest.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Three Areas
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;1.Working Directory&lt;/strong&gt;: Your project as it sits on your laptop (e.g., a new file.txt you just created).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.Staging Area&lt;/strong&gt;: When you run &lt;code&gt;git add .&lt;/code&gt;, Git starts "watching" those specific changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.Repository&lt;/strong&gt;: After you &lt;code&gt;git commit&lt;/code&gt;, the changes are saved locally. Finally, &lt;code&gt;git push&lt;/code&gt; sends them to the GitHub repository.&lt;/p&gt;

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

&lt;p&gt;Advanced Survival Commands&lt;br&gt;
&lt;strong&gt;git pull&lt;/strong&gt;: This is fetch + merge. it brings all changes from your friends and updates your code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git fetch&lt;/strong&gt;: Safely brings remote branches for you to look at without merging them into your work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;git stash&lt;/strong&gt;: If you need to change branches but aren't ready to commit, git stash hides your changes. Use git stash pop to bring them back when you return.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Merge vs. Rebase&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Merge&lt;/strong&gt;: Safe, but the history isn't linear because each merge is a new commit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rebase&lt;/strong&gt;: Rewrites the commit history to make it linear. Be careful with a team; it can be confusing as it changes history!&lt;/p&gt;
&lt;h2&gt;
  
  
  Don't Fear Conflicts
&lt;/h2&gt;

&lt;p&gt;Conflicts occur when two people edit the same line. Your editor will open and show you:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD
def calculate_total(price, tax):
    return price + (price * tax)
=======
def calculate_total(price, tax_rate):
    return price * (1 + tax_rate)
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; feature-optimization
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&lt;/code&gt; is your local version; &lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; feature-optimization&lt;/code&gt; is the incoming change. You can accept "current," "incoming," or "both."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check Status&lt;/strong&gt;: &lt;code&gt;git status&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stage the Fix&lt;/strong&gt;: &lt;code&gt;git add &amp;lt;filename&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Complete&lt;/strong&gt;: &lt;code&gt;git commit&lt;/code&gt; (if merging) or &lt;code&gt;git rebase --continue&lt;/code&gt;. (You can always use &lt;code&gt;git rebase --abort&lt;/code&gt; to stop without breaking anything).&lt;/p&gt;

&lt;h3&gt;
  
  
  Security &amp;amp; Undoing Mistakes
&lt;/h3&gt;

&lt;p&gt;The .env trick: If you forgot to add a .env file to your .gitignore and accidentally committed it, you can stop tracking it without deleting it from your computer using:&lt;br&gt;
&lt;code&gt;git rm --cached &amp;lt;file&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Going Back:
&lt;/h3&gt;

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

&lt;p&gt;&lt;code&gt;git checkout &amp;lt;commit-hash&amp;gt;&lt;/code&gt;: Moves your location. If you see "Detached HEAD," it just means your pointer isn't on the latest branch tip.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git reset --soft HEAD~1&lt;/code&gt;: Undoes the last commit but keeps changes in the staging area.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git reset --mixed&lt;/code&gt;: (Default) Undoes the commit and the stash (cache); code stays in your working directory.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git reset --hard&lt;/code&gt;: Dangerous. Reverts your directory to look exactly like an old commit; everything else is deleted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Secret Weapon&lt;/strong&gt;: If you make a mistake with --hard, use git &lt;code&gt;reflog&lt;/code&gt;. It’s like a recycle bin for your commits.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git revert&lt;/code&gt;: Creates a new commit that does the opposite of a previous commit to "undo" it safely.&lt;/p&gt;

&lt;p&gt;"&lt;em&gt;Finally figuring out that git commands are strangely named graph manipulation commands—creating/deleting nodes, moving pointers around&lt;/em&gt;." — Kent Beck&lt;/p&gt;

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