今日已更新 344 条资讯 | 累计 37249 条内容
关于我们

Understanding the Git Workflow: Working Directory, Staging, Commit and Push

Joe 2026年08月23日 10:58 2 次阅读 来源:Dev.to

Working through a practical reference to moving a change through Git took me through the process of taking a single change from my local computer, committing it in Git, and pushing it to GitHub where others would be able to see it. This was written for complete Git Novices and so I approached it without any prior experience of using Git. By the end, you will be able to move a change through all four Git stages and confirm it's visible on GitHub with a clear commit history. Who This Is For Anyone that want to work with Git in the terminal Users who find git add , git commit , and git push unclear No prior Git experience required Prerequisites Git installed ( git --version to check) A terminal or command-line application A GitHub account (create one if needed) We'll use a small sales data project as a running example. You do not need Python or Pandas installeda as we will be only tracking files, not running code. The Four-Stage Flow Every change travels in one direction: Working Directory → Staging Area → Local Repository → Remote Repository Working directory : where everything is worked on Staging area : choosing what goes in Commit : your historical record for everything worked on Push : share it so collaborators can see it Setup: Initialize a Repository Create a project folder and make it a Git repository: mkdir monthly-sales cd monthly-sales git init Expected output: Initialized empty Git repository in /path/to/monthly-sales/.git/ git init creates a hidden .git folder where Git stores the entire history. From now on, Git watches this folder. Usage 1. Working Directory (Untracked Files) Create a raw data file: echo "date,region,revenue" > sales_data.csv echo "2026-01-01,East,1200" >> sales_data.csv Check its status: git status Expected output: On branch main No commits yet Untracked files: (use "git add <file>..." to include in what will be committed) sales_data.csv Untracked means Git can see the file but isn't following it yet. This is the default for new files.

本文内容来源于互联网,版权归原作者所有
查看原文