How my journey at Frisco became memorable

Traveling is most certainly one of the best activities for both the soul and the body. You get the chance to discover different cultures and experience uncommon realities, rest your brain and revive…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Git and Version Control

One of the in demand skill for developers.

Hey there👋

Getting started with Git and Version Control?

This article is just the very best for you. I recently started learning about version control system and I’m already getting excited about it all. So, without further ado, let’s hop into it.🚀

What is Version Control?

Version control also called source control is the act of tracking and managing changes one made to files.

Version Control Systems

The Version Control Systems are systems that keep record of the changes made to a setup file. The system refers to the category of software tools that make it possible for the software team to look after the source code changes whenever needed. The system records all the made changes to a file so a specific version may be rolled if required in the future.

The responsibility of the Version control system is to keep all the team members on the same page. It makes sure that everyone on the team is working on the latest version of the file and, most importantly, makes sure that all these people can work simultaneously on the same project.

Popular Version Control System

Some of the popular version control systems are:

For the purpose of this article we will focus on using Git and GitHub for version control and collaboration.

What then is Git?

Git is a popular version control system. It is basically used for:

GitHub

GitHub is a platform for hosting code for version control and collaboration. It helps you and others works together on a project from anywhere in the world.

Git Configuration

Now that you’ve downloaded and installed Git, to check if it is properly installed on your system:

Open your command shell and run this command: git --version, and hit enter. If you have Git properly installed, it should show the version of Git you installed.

Now, having made sure that you have Git installed, next is to let git know who you are. This is done by setting up your username and email. It is advisable to use your GitHub username and email for this. This helps Git to track who makes changes.

To setup your username: git config — global user.name “yourusername”

To setup your email: git config — global user.name “youremail”

If you have this done properly, use git config --global --list to check. It will list both your username and email.

Git Commands

Git commands are the commands that comes with git used to make changes to files, tracked code changes, and for coding collaboration.

Let’s look at some the Git commands:

Git init: The git init command creates a new Git repository. It can be used to convert an existing project to a Git repository or initialize a new, empty repository.

Git status: The git status command displays the state of the working directory and the staging area. It lets you see which changes have been staged, which haven’t, and which files aren’t being tracked by Git.

Git add: The git add filename (single file) or git add .(all files in the current directory) command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit. However, git add doesn’t really affect the repository in any significant way — changes are not actually recorded until you run git commit .

Git commit: The git commit -m “commit message” command captures a snapshot of the project’s currently staged changes. Committed snapshots can be thought of as “safe” versions of a project — Git will never change them unless you explicitly ask it to.

Git branch: The git branch branchnamecommand is used to create a new/separate version of the main repository. Let’s say you have a large project, and you need to update the design on it.

Git checkout: The git checkout branchname command lets you navigate between the branches created by git branch . Checking out a branch updates the files in the working directory to match the version stored in that branch, and it tells Git to record all new commits on that branch.

How to use GitHub to Host Codebase Online

What the Commands Does

The git remote add origin is a command that enables developers to work on a central remote repo by creating remote duplicates. Remote add command serves as a means through which collaborators for a project can independently make commits for a shared project. The remote add function in git also allows fetching changes made from the remote server to local. When using git, you must learn how to switch between the central remote to your own. That way, you can maintain all the status updates and make contributions through the push and fetch git methods.

The git branch -M main command changes your branch from master to main. This is because initially, when you did git init your default branch was master.

The git push -u origin main command pushes your codes from your system to online( repository you created on GitHub). The origin is just like a placeholder that holds your repository's url. When this command is executed. Note that you can also push as many branch as you wish using git push -u origin branchname.

Cloning Repository for Collaboration

Git Workflow

Git workflow is basically a recipe or recommendation for how to use Git to accomplish work in a consistent and productive manner. Git workflows encourage developers and DevOps teams to leverage Git effectively and consistently.

When you clone a group repository, it is advisable not to work on the main or master branch. The main or master branch should serve like a container where the works from all other branches will be gathered together for deployment. So, when you are added to a project, the best thing is to create a branch you can work from. In so doing, you can have a clean main or master branch. So if anything happens in the branch you created you can always refer to main as source. Every changes is always going to main so before you push it is advisable you git pull origin main from main into your own branch.

Pull Request(PR)

Pull request is requesting for your code to be merged to another branch online. i.e requesting for your code to be pulled into a different branch. During your PR, it is also advisable to add reviewers who check your codes before your codes are approved to be merge.

In Conclusion

as a developer the knowledge of Git and GitHub is very vital and can not be overemphasized. It provides access to previous versions of the project. If there is any mistake, we can always roll back or undo the changes without losing any work.

GIT is a hero that helps us handle possible problems that may occur while working on a software project.

I become more acquainted with git commands the more I use them, so I urge you to go on and practice what you just learnt.

Add a comment

Related posts:

My Person

Do you ever look at someone and not see them…instead you see right through them? Every inch of you is telling you that you know them, but there is this voice in the back of your head that asks if you…

Holy Trinity

In the book of Instagram, well-being is the new religion. We see this through yoga shots by the sunset, beautiful selfies in an exotic destination and artistic self-portraits in a high-contrast city…

Citrine Macro

Citrine is one I am INCREDIBLY attracted to right now. It’s like no matter where I look, someone is talking about it or sharing pictures of it. PeaceLoveMeditate has these INCREDIBLE pieces which are…