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

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

Waweru 2026年08月22日 17:52 5 次阅读 来源:Dev.to

Introduction Git is a version control system that tracks changes in code. When writing code we need to save every significant change or feature that does a certain function as a commit that can be reverted to if we ever need that instance of the code. This helps programmers to traverse code since nothing is ever lost in the product life cycle of the project. It also helps in debugging since we have a copy of the previous working state. So how do we start out with git you ask. Install git Install git for your specific operating system. After installing git you will note that the file comes with git bash which is a command line terminal that is used to run commands or instruct the version control git. To ensure that git has been installed open git bash and run the command git --version which will return the version of git installed Download Visual Studio Code Install VS code a text editor for writing code. Create a github account GitHub is a cloud-based platform used by developers to store, track, and collaborate on software code. It operates as a hosting service for git, an open-source version control system that tracks changes made to files. Head over to github and create and account Creating a directory tracked by git On git bash run mkdir <filename> . This will create a folder ie the project that will contain your files of code. Enter the folder through cd <filename> and create a file README.md file which explains what this project does touch README.md . Run the command ls to list files in the directory Open the vs code from terminal by running code . and edit the README.md file. Now the file is ready to be tracked by git on github Staging, committing and pushing We now need to initialize the directory making sure that git is now tracking the file. Running the commands ls-la will confirm that git has been initialized in the repository. There are two ways of doing this either via the text editor VS code or the terminal . Let us go through both. 1. VS code Make sure

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