<?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: Njuguna Gichia</title>
    <description>The latest articles on DEV Community by Njuguna Gichia (@9ichia).</description>
    <link>https://dev.to/9ichia</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%2F4070940%2Fe33301ec-ee23-4ff3-a005-1c7261ff3b79.png</url>
      <title>DEV Community: Njuguna Gichia</title>
      <link>https://dev.to/9ichia</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/9ichia"/>
    <language>en</language>
    <item>
      <title>Understanding the Git Workflow: Working Directory, Staging, Commit and Push.</title>
      <dc:creator>Njuguna Gichia</dc:creator>
      <pubDate>Sat, 22 Aug 2026 20:20:07 +0000</pubDate>
      <link>https://dev.to/9ichia/understanding-the-git-workflow-working-directory-staging-commit-and-push-226i</link>
      <guid>https://dev.to/9ichia/understanding-the-git-workflow-working-directory-staging-commit-and-push-226i</guid>
      <description>&lt;p&gt;Two weeks ago, I joined a Data Science bootcamp and part of the learning outcomes for this week was independently navigating the Git Workflow to successfully upload a test project as part of the data portfolio to a GitHub repository. &lt;/p&gt;

&lt;p&gt;Git is a version control system that runs locally on a personal computer and allows us to keep track of changes made to our projects. Git creates saved checkpoints knowns as commits that act as snapshots of the state of the projects. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; is an online service where we can store Git repositories. While Git is installed and works locally on our personal computers, GitHub stores our repositories online and allows us to share and collaborate on projects &lt;/p&gt;

&lt;p&gt;My project was a custom energy consumption segmentation analysis using k means. Other than local python, this project required additional installation of &lt;code&gt;pandas&lt;/code&gt;, &lt;code&gt;numpy&lt;/code&gt; for data processing and manipulation, &lt;code&gt;scikit-learn&lt;/code&gt; for preprocessing, and &lt;code&gt;matplotlib&lt;/code&gt; and &lt;code&gt;seaborn&lt;/code&gt; for the data visualization. &lt;/p&gt;

&lt;p&gt;The Git workflow happened in 4 distinct stages.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Working Directory.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The working directory is the folder containing my project files where the terminal or Git is currently working from. These include: &lt;br&gt;
    - &lt;strong&gt;&lt;code&gt;README.md&lt;/code&gt;&lt;/strong&gt; file which is a description of the entire project written in raw markdown. It contains information about the project such as:&lt;br&gt;
        - What the project is about&lt;br&gt;
        - What dataset was used&lt;br&gt;
        - The tools used &lt;br&gt;
        - The analysis was performed&lt;br&gt;
        - Contents of each folder&lt;br&gt;
        - Important findings&lt;br&gt;
        - How another person can understand the project&lt;br&gt;
    - &lt;strong&gt;&lt;code&gt;Data&lt;/code&gt;&lt;/strong&gt; Folder which contains an excel spreadsheet named &lt;code&gt;energy_consumption_data.csv&lt;/code&gt; that contained the consumer data.&lt;br&gt;
    - &lt;strong&gt;&lt;code&gt;Scripts&lt;/code&gt;&lt;/strong&gt; Folder which contains a K means python script named &lt;code&gt;segmentation.py&lt;/code&gt;. Python script files typically end with the &lt;code&gt;.py&lt;/code&gt; extension.&lt;/p&gt;

&lt;p&gt;To create a working directory using Git Bash, I opened Gitbash on Desktop by clicking on the windows icon on the taskbar, typing in &lt;code&gt;bash&lt;/code&gt; and clicking on Gitbash to open a new window. Once the window was open, I ran &lt;strong&gt;&lt;code&gt;cd Desktop&lt;/code&gt;&lt;/strong&gt;, to navigate to my Desktop where I created a new Folder Titled &lt;code&gt;energy_consumption_analysis&lt;/code&gt; by running the command &lt;/p&gt;

&lt;p&gt;&lt;code&gt;mkdir energy_customer_data_analysis&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;The command &lt;code&gt;cd&lt;/code&gt; means change directory and it allows you to navigate in and out of directories. &lt;code&gt;cd&lt;/code&gt; allows you to enter a folder while &lt;strong&gt;&lt;code&gt;cd ..&lt;/code&gt;&lt;/strong&gt; allows you to move backward by exiting a directory or a folder into the parent directory. Inside &lt;code&gt;energy_customer_data_analysis&lt;/code&gt;, I created two folders &lt;code&gt;Data&lt;/code&gt; and &lt;code&gt;Scripts&lt;/code&gt; simultaneously by running the &lt;strong&gt;&lt;code&gt;mkdir&lt;/code&gt;&lt;/strong&gt; command which allows you to create 2 folder simultaneously by listing two folder names separated by a space: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;mkdir Data Scripts&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;command created two folders named &lt;code&gt;Data&lt;/code&gt; and &lt;code&gt;Scripts&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;I also created the &lt;code&gt;README.md&lt;/code&gt; file by running &lt;strong&gt;&lt;code&gt;touch README.md&lt;/code&gt;&lt;/strong&gt; in bash.&lt;/p&gt;

&lt;p&gt;to make sure that I had created all the files and folders, I ran the &lt;strong&gt;&lt;code&gt;ls&lt;/code&gt;&lt;/strong&gt; command in bash which allowed me to see all the files and folders created in the working directory.&lt;/p&gt;

&lt;p&gt;I copied the CSV file from my downloads into the &lt;code&gt;Data&lt;/code&gt; folder then used bash to navigate into the &lt;code&gt;Scripts&lt;/code&gt; folder by running &lt;strong&gt;&lt;code&gt;cd Scripts&lt;/code&gt;&lt;/strong&gt; since I was still inside my project folder. once inside the Scripts folder, I ran &lt;strong&gt;&lt;code&gt;touch segmentation.py&lt;/code&gt;&lt;/strong&gt; to create the python script file and then ran &lt;strong&gt;&lt;code&gt;code .&lt;/code&gt;&lt;/strong&gt; in bash to then open &lt;code&gt;segmentation.py&lt;/code&gt; in VS Code.  &lt;/p&gt;

&lt;p&gt;After writing the python code in VS Code, I went back to bash and ran &lt;code&gt;cd ..&lt;/code&gt; to exit the scripts folder and ran &lt;code&gt;nano README.md&lt;/code&gt; to open the README file in Bash's text editor &lt;code&gt;nano&lt;/code&gt; where i wrote the description for the project in Markdown. Once this was complete, &lt;code&gt;Ctrl + O&lt;/code&gt;, then &lt;code&gt;Enter&lt;/code&gt; to save then &lt;code&gt;Ctrl + X&lt;/code&gt; to go back to bash. To see what's inside the README file, use &lt;code&gt;cat README.md&lt;/code&gt; in bash to display text inside the &lt;code&gt;README.md&lt;/code&gt; file and &lt;code&gt;ls&lt;/code&gt; to inspect the project folder. Once satisfied with everything, we then move on to the next step.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Staging Area.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The staging area is the preparation area for the next commit. Here, we Initialize Git, check changes and stage files. Before running any git commands, we check our location by running &lt;strong&gt;&lt;code&gt;pwd&lt;/code&gt;&lt;/strong&gt; . &lt;code&gt;Pwd&lt;/code&gt; means print working directory and allows us to see the exact location we are working from. &lt;/p&gt;

&lt;h3&gt;
  
  
  Initialize git
&lt;/h3&gt;

&lt;p&gt;Once we ascertain that we are in the correct project folder, we can initialize git by running the command &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;git init&lt;/code&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;which instructs Git to begin managing the project. When run successfully, we should see : `Initialized empty Git repository in (the working directory path)&lt;/p&gt;

&lt;p&gt;We also run &lt;strong&gt;&lt;code&gt;ls -la&lt;/code&gt;&lt;/strong&gt; which allows us to see a &lt;code&gt;.git&lt;/code&gt; folder which acts as Git's internal memory for the project. &lt;/p&gt;

&lt;h3&gt;
  
  
  Check Project Status
&lt;/h3&gt;

&lt;p&gt;We check project status by running &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;git status&lt;/code&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;This allows git to show us exactly what is happening in our project and because this is a completely new project and repository that git has not started tracking, our project status is untracked.&lt;/p&gt;

&lt;h3&gt;
  
  
  Project Staging
&lt;/h3&gt;

&lt;p&gt;We can add individual files in our directory by running &lt;code&gt;git add &amp;lt;filename&amp;gt;&lt;/code&gt; to select the individual file or we can run &lt;strong&gt;&lt;code&gt;git add .&lt;/code&gt;&lt;/strong&gt; to add everything in the current directory. This moves the selected files from the working directory into the staging area. &lt;/p&gt;

&lt;p&gt;We can check the status of our project by running &lt;code&gt;git status&lt;/code&gt; and if the staging is successful, our selected files and folders should be listed in green. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Commit.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;We create the first commit by running &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;git commit -m "Add Energy Consumption Segmentation Analysis Project"&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git commit&lt;/code&gt; creates a saved Git checkpoint while &lt;code&gt;-m&lt;/code&gt; means the message we want to attach to the commit which in this case is &lt;code&gt;"Add Energy Consumption Segmentation Analysis Project"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The message explains what was saved. A good commit message creates an understandable history of the project. &lt;/p&gt;

&lt;h3&gt;
  
  
  Commit History
&lt;/h3&gt;

&lt;p&gt;We can view the commit history by running &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;git log&lt;/code&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;which shows us the commit history or by running:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;git log --oneline&lt;/code&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;for a much shorter commit history. &lt;/p&gt;

&lt;h3&gt;
  
  
  Creating the Github Repository.
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;We can create a new repository in GitHub through our browser.&lt;/li&gt;
&lt;li&gt;Go to &lt;strong&gt;Github.com&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;Sign in.&lt;/li&gt;
&lt;li&gt;Once Signed in Click the &lt;code&gt;+&lt;/code&gt; button.&lt;/li&gt;
&lt;li&gt;Select: &lt;strong&gt;New repository&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Enter &lt;strong&gt;Repository Name(e.g.,&lt;a href="https://github.com/njugunagichia/Energy-Consumer-Data-Segmentation-Analysis" rel="noopener noreferrer"&gt; &lt;code&gt;energy_consumer_data_segmentation_analysis&lt;/code&gt;&lt;/a&gt;&lt;/strong&gt;)&lt;/li&gt;
&lt;li&gt;You can also Add an optional description such as:(&lt;code&gt;energy_consumer_data_analysis_using_Python&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Choose between a &lt;strong&gt;Public&lt;/strong&gt; or &lt;strong&gt;Private&lt;/strong&gt; Repository (keep in mind that a public repository can generally be viewed by anyone and should not be used for sensitive or confidential data. In our case, the data is synthetic and non-specific so a public repository is fine.) &lt;/li&gt;
&lt;li&gt;Leave options such as: &lt;strong&gt;Add README&lt;/strong&gt;, &lt;strong&gt;Add .gitignore&lt;/strong&gt;, and &lt;strong&gt;Add license unchecked.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Create New Repository.&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After creating the repository, navigate to the connection options, Select &lt;strong&gt;SSH&lt;/strong&gt; if you have it already configured.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Push.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Pushing means sending committed changes on our projects to GitHub.&lt;/p&gt;

&lt;p&gt;After copying the SSH string, return to Git Bash. To check whether we are still in the project, run &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;pwd&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If still in the folder, run: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;git remote add origin git@github.com:USERNAME/project-name.git&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;USERNAME&lt;/code&gt;&lt;/strong&gt;: is your GitHub Username&lt;br&gt;
&lt;strong&gt;&lt;code&gt;Project-name.git&lt;/code&gt;&lt;/strong&gt;: is the name of the repository you've just created.&lt;/p&gt;

&lt;p&gt;type &lt;strong&gt;&lt;code&gt;git remote add origin&lt;/code&gt;&lt;/strong&gt; and then press &lt;code&gt;Shift + Insert&lt;/code&gt; on your keyboard to paste the SSH string  you've just copied from GitHub to complete the command and then run it. &lt;/p&gt;

&lt;h3&gt;
  
  
  Checking the Remote.
&lt;/h3&gt;

&lt;p&gt;A remote is a connection between our local repository and another repository which is in our case, the one on GitHub. &lt;/p&gt;

&lt;p&gt;We check the remote by running: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;git remote -v&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;origin git@github.com:USERNAME/project-name.git (fetch)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;means that Git can retrieve information from the remote repository&lt;/p&gt;

&lt;p&gt;&lt;code&gt;origin git@github.com:USERNAME/project-name.git (push)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;means that git can send commits to the remote Repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pushing the Code
&lt;/h3&gt;

&lt;p&gt;Pushing means sending the committed changes in my project to the Remote Git Repository.&lt;/p&gt;

&lt;p&gt;we do this by running: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;git push -u origin main&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Bash will prompt you to enter the configured passphrase. if you have one, type it in and then &lt;strong&gt;Enter&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Verifying the Push
&lt;/h3&gt;

&lt;p&gt;Return to the repository page on your browser and refresh it. &lt;br&gt;
GitHub should render the contents in your &lt;code&gt;README.md&lt;/code&gt; file visually.&lt;br&gt;
You should also be in a position to see your files and the contents in those files (i.e the CSV file in the &lt;code&gt;Data&lt;/code&gt; folder and the &lt;code&gt;.py&lt;/code&gt; file in the &lt;code&gt;Scripts&lt;/code&gt; folder).&lt;/p&gt;

&lt;p&gt;If we can see this, then our project has successfully been pushed to GitHub.&lt;/p&gt;

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