Introduction
The world is experiencing technological advancement in a very fast pace, hence this article is meant to provide a very simple understanding of Git Workflow for beginners who are stepping in to to the space of software development or BigData. Understanding of Git workflow is important because Git is widely utilized version of control system in most of the software development and data analytics. This is because; t assits developers to monitor and track changes to files they working on,it facilitates collaboration and experimentation of ideas and provides safe platform to main projects in different versins.
In the initial stages Git might seem complex and confusing because of introduction of commands and concepts that we do not encounter in any normal file management workflow.Commands such as working directory, staging area, commit and push.These concepts are very important as they highlight the levels and stages in which changes move and occur when using Git.
Four Main Stages of Git Workflow
The Working Directory
This is simple terms a folder on your PC where all projects lives. Every time a code editor is opened and you start typing, files will be modified in the working directory.At this moment Git is alert and aware however not executing and tracking the changes.
The main action when wanting to view files on the working directory is git status. When this command is typed on the terminal, git will display all list of files which have been changed. At this particular stage however the files are "untracked".
The Staging Area
This is the middle ground in Git i.e a temporal holding zone. This is where one gathers files and saves then in the next version.The Staging Area is very key because you might having 5 changes in 2 diffirent files, however only 2 changes and okay and complete.No one likes incomplete work hence can never save it. The Staging Area provides an opportunity to save selectively.We use the command addthe completed files and leaving the unfinished to the working directory.
The command here is git add <filename>
If all changes have to be added in the current folder, we use the command git add . git takes holds of those particular files and stages them in the Staging Area.
The Local Repository
After all the changes in your files have been staged, they can be saved in the Local Repository. The processing of saving the files is executed by a Commit command which is the most crucial Git command.When you run a "commit" command, it takes the files sitting at the Staging Area, moving and storing them permanently in the Local Repository
Git usually gives every commit a code because each commit is unique. Additionally every commit needs a message. This message highlights the changes made and the reason they were made.
The command used is git commit -m "The Commit Message"
Important points to note;
The commit massage is always in present tense.
Commit are usually permanent ie the version has been saved forever. This can only be reversed by forcing a reset.
The Remote Repository
Up to the local repository, files exist only on your computer.A Remote Repository hosts copy of your files or project on the internet.Examples of platform to host files on the internet are:
Github
Bitbucket
Gitlab
We use thepushcommand to uploading committed changes to the Remote Repository from the Local Repository.
The command to push commits isgit push origin <branch-name>
In this case the default branch ismainhence the command will begit push origin main. Your work has been backed up safely.
Summary
The most simple way to understand the above mentioned stages to just get rif of the mystery around Git is highlighted below:
Write it-Prepare it-Save it locally-Upload to cloud.
We should strive to understand the stages rather than memorizing the commands,this is because understanding where changes are taking place at each stage is the key.Once we master this movement and how changes occur from the working directory all the way to remote repository, understanding additinal commands like merging, branches and pull become easy to understand.
Top comments (0)