Introduction
During the onboarding phase of data science and analytics program at LuxDevHq, Git and GitHub were one of the most critical tools we learned that work together to manage projects.
Git: Is installed, runs on the computer and keeps track of changes made to the project.
GitHub: is an online service where you can store Git repositories, the account is created online.
To connect both Git and GitHub we used Git Bash and authenticated using SSH (Secure Shell), this ensures a secure seamless connection for transferring a project.
The stages of Git workflow
Working directory
Working directory is a local workspace that is used to actively create and interact with files and folder in Git bash environment.
We used the following commands to navigate the files and folders;
-
cd desktopto open desktop folder when you’re inside the user profile folder -
LsListing all the files and folders -
Mkdircreating files and folders of your project -
Touchcreating a README.md file that explains the contents of the project -
Echotyping content of README.md -
Nanotyping longer version of content of README.md file -
Cat README.mdto see the content of README.md file -
Git initinitializing the directory as a git repository -
Git statushelps to see if there are commits
Staging
The staging area is where we selected and organized the specific changes in the working directory so as to include in the next checkpoint. Staging files prepares files and folders locally but does not upload anything to GitHub.
For example, we used the following commands for the files to be saved;
git add README.md to stage README.MD file
git add . to stage all changes in the current directory at once ,and
git status list these files under changes to be committed.
Commit
When we performed commit command, Git takes whatever is currently in the staging area and saves it as a permanent local checkpoint called a commit.
Committing does not upload the files to GitHub; it remains on the computer.
Example: When we run the command
git commit -m "Add Kenyan hospital health records analysis project
Git saved this snapshot locally, which we can always refer back to it later if needed.
Pushing
Pushing uploads the local commits to the remote server so the work is safely backed and can be shared with others.
When we run
git push -u origin main
it connects the local branch to GitHub and upload the first commit and for subsequent changes like updating the README file later—we simply run git push
Once all this process of staging, commit and push is complete, refreshing the repository page on GitHub shows the project folders and files online.
Conclusion
In conclusion we learned the Git workflow through memorizing and understanding this sequence
git status (Check) --> git add . (Prepare) --> git commit (Save checkpoint) --> git push (Upload)
Top comments (1)
I appreciate how you broke down the Git workflow into digestible steps, especially the focus on staging and committing, which are crucial for maintaining a clean project history. One practical insight is to encourage the use of meaningful commit messages; this not only aids in tracking changes but also helps other collaborators understand the project’s evolution at a glance. If you're considering expanding this resource into a more comprehensive guide or tool, I'd be happy to discuss a paid collaboration to help enhance the project further. How have your team’s experiences with Git influenced your approach to version control best practices?