<?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: Collins Muatha</title>
    <description>The latest articles on DEV Community by Collins Muatha (@collins_muatha_d018e04d99).</description>
    <link>https://dev.to/collins_muatha_d018e04d99</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4071870%2Fab6971cc-3be4-4821-8a20-b7c5ce6a70a2.jpg</url>
      <title>DEV Community: Collins Muatha</title>
      <link>https://dev.to/collins_muatha_d018e04d99</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/collins_muatha_d018e04d99"/>
    <language>en</language>
    <item>
      <title>Understanding the Git Workflow: Working Directory, Staging, Commit and Push</title>
      <dc:creator>Collins Muatha</dc:creator>
      <pubDate>Sat, 29 Aug 2026 19:14:32 +0000</pubDate>
      <link>https://dev.to/collins_muatha_d018e04d99/understanding-the-git-workflow-working-directory-staging-commit-and-push-ijf</link>
      <guid>https://dev.to/collins_muatha_d018e04d99/understanding-the-git-workflow-working-directory-staging-commit-and-push-ijf</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;When I first started learning Git, commands such as' git add',&lt;br&gt;
'git commit', and 'git push' seemed confusing. I later understood&lt;br&gt;
that each command represents a different stage in saving and sharing&lt;br&gt;
project changes.&lt;/p&gt;

&lt;p&gt;In this article, I explain the Git workflow using a small practical&lt;br&gt;
project.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Git?
&lt;/h2&gt;

&lt;p&gt;Git is a version control system that records changes made to files.&lt;br&gt;
It allows developers to track project history, return to earlier&lt;br&gt;
versions, and work safely on projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Git workflow
&lt;/h2&gt;

&lt;p&gt;The basic workflow is:&lt;/p&gt;

&lt;p&gt;Working directory → Staging area → Commit → Remote repository&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Working directory
&lt;/h2&gt;

&lt;p&gt;The working directory is the project folder on my computer.&lt;br&gt;
When I create or edit &lt;code&gt;README.md&lt;/code&gt;, the changes first exist here.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;'''bash&lt;br&gt;
mkdir git-workflow-demo&lt;br&gt;
cd git-workflow-demo&lt;br&gt;
'''&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Initialize a Git repository
&lt;/h2&gt;

&lt;p&gt;'''bash&lt;br&gt;
git &lt;a href="https://dev.tourl"&gt;init&lt;/a&gt;&lt;br&gt;
'''&lt;/p&gt;

&lt;p&gt;This command tells Git to start tracking the project.&lt;/p&gt;

&lt;p&gt;To check the status:&lt;/p&gt;

&lt;p&gt;'''bash&lt;br&gt;
git status&lt;br&gt;
'''&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Staging area
&lt;/h2&gt;

&lt;p&gt;The staging area allows me to choose which changes should be included&lt;br&gt;
in the next commit.&lt;/p&gt;

&lt;p&gt;'''bash&lt;br&gt;
git add README.md&lt;br&gt;
'''&lt;/p&gt;

&lt;p&gt;To stage all files:&lt;/p&gt;

&lt;p&gt;'''bash&lt;br&gt;
git add .&lt;br&gt;
''''&lt;/p&gt;

&lt;p&gt;The staging area is useful because I may have several changes in my&lt;br&gt;
working directory but only want to save some of them in one commit.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Commit
&lt;/h2&gt;

&lt;p&gt;A commit is a saved snapshot of the staged changes.&lt;/p&gt;

&lt;p&gt;'''bash&lt;br&gt;
git commit -m "Add first Git workflow demo"&lt;br&gt;
'''&lt;/p&gt;

&lt;p&gt;A good commit message should be short and meaningful.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Connect the project to GitHub
&lt;/h2&gt;

&lt;p&gt;After creating a repository on GitHub, I connect it to my local project:&lt;/p&gt;

&lt;p&gt;'''bash&lt;br&gt;
git remote add origin &lt;a href="mailto:git@github.com"&gt;git@github.com&lt;/a&gt;:YOUR-USERNAME/git-workflow-demo.git&lt;br&gt;
'''&lt;/p&gt;

&lt;p&gt;I can confirm the connection with:&lt;/p&gt;

&lt;p&gt;'''bash&lt;br&gt;
git remote -v&lt;br&gt;
'''&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Push changes to GitHub
&lt;/h2&gt;

&lt;p&gt;'''bash&lt;br&gt;
git branch -M main&lt;br&gt;
git push -u origin main&lt;br&gt;
'''&lt;/p&gt;

&lt;p&gt;The 'git push' command uploads local commits to the GitHub repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making another change
&lt;/h2&gt;

&lt;p&gt;After editing the file again, I can repeat the workflow:&lt;/p&gt;

&lt;p&gt;'''bash&lt;br&gt;
git status&lt;br&gt;
git add README.md&lt;br&gt;
git commit -m "Update project explanation"&lt;br&gt;
git push&lt;br&gt;
'''&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Forgetting to stage changes
&lt;/h3&gt;

&lt;p&gt;If I commit without running &lt;code&gt;git add&lt;/code&gt;, Git may report that there is&lt;br&gt;
nothing to commit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using an unclear commit message
&lt;/h3&gt;

&lt;p&gt;A message such as &lt;code&gt;changes&lt;/code&gt; does not explain what was changed.&lt;br&gt;
A message such as &lt;code&gt;Update README instructions&lt;/code&gt; is clearer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pushing before configuring the remote
&lt;/h3&gt;

&lt;p&gt;If Git does not know the GitHub repository address, I must first run:&lt;/p&gt;

&lt;p&gt;'''bash&lt;br&gt;
git remote add origin REPOSITORY-URL&lt;br&gt;
'''&lt;/p&gt;

&lt;h3&gt;
  
  
  Sharing a private SSH key
&lt;/h3&gt;

&lt;p&gt;The private key must remain on my computer. Only the public key should&lt;br&gt;
be added to GitHub.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The Git workflow is easier to understand when viewed as a sequence:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make changes in the working directory.&lt;/li&gt;
&lt;li&gt;Select changes with 'git add'.&lt;/li&gt;
&lt;li&gt;Save a snapshot with 'git commit'.&lt;/li&gt;
&lt;li&gt;Upload the commit with 'git push'.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This small project helped me understand how local work is tracked and&lt;br&gt;
shared on GitHub.&lt;/p&gt;

&lt;h2&gt;
  
  
  Useful commands
&lt;/h2&gt;

&lt;p&gt;''''bash&lt;br&gt;
git status&lt;br&gt;
git add .&lt;br&gt;
git commit -m "Meaningful message"&lt;br&gt;
git log --oneline&lt;br&gt;
git remote -v&lt;br&gt;
git push&lt;br&gt;
''''&lt;/p&gt;

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