Yassine BENNKHAY
Yassine BENNKHAY's Blog

Yassine BENNKHAY's Blog

The Git basics you should know!

The Git basics you should know!

Subscribe to my newsletter and never miss my upcoming articles

I started learning Git some days ago and I would like to share what I have simply learned with you. without any further words let’s get started with the main question what’s Git?

Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. In this list, I’m gonna share with you the most important commands you should know to let you going with Git. First thing is to tell git who you are by running these two commands:

git config — global user.name “your name”
git config — global user.email something@example.com

these two lines configure the author name and email address to be used with your commits. now when you created the author name and email, you need to create a new local repository inside your working directory by running this command:

git init

if you want to list the files you’ve changed and those you still need to add or commit run git status probably will see in the console “nothing to commit, working tree clean” and it’s normal because no action was taken yet! so you need to run

git add

(we consider that you made a change in your code before running this command). The command

git add

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 that commit changes to head (but not yet to the remote repository). branches are important during the development process and you can create and navigate to them by running this command

git checkout -b branch-name

also to switch between one branch to another use

git checkout branch-name

also to list all the branches in your repo, and also tell you what branch you’re currently in.

 git branch

is the command for that. to show file in the staging area you can simply type this command:

git ls-files

It’s all for this first article I hope you’ll find it helpful, in the next one we will dive into how to deleting data, till then Thanks for reading, and have a great day. Yassine BENNKHAY.

 
Share this