Basics of Git

GIT is the most widely used open-source version control system that allows you to track changes made to files. Programmers usually use GIT to collaborate on developing software.

A GIT project consists of three major sections: the working directory, the staging area, and the git directory.

The working directory is where you add, delete, and edit the files. Then, the changes are staged in the staging area. After you commit your changes, the snapshot of the changes will be saved into the git directory.

Below are the basic Git Commands that every web developer should know

Prerequisite Before you start using Git, you have to make it available on your computer. Even if it’s already installed, it’s probably a good idea to update to the latest version. Installation instructions can be found here: Link

1. git init The git init command is used to initialize a new Git repository. This command can be used to set up a new repository or to convert an existing project to a Git repository. It creates a new directory that contains all of the necessary Git files, such as the .gitignore file and the .gitattributes file.

2. git status The git status command is a powerful tool that allows you to see the current state of your git repository. This command can be used to see which files have been modified, which files are new, and which files are not being tracked by git. It is also helpful in seeing which branch you are currently on and which files would be included in a commit.

3. git add The git add command is used to add files to the staging area. The staging area is a temporary location where changes are stored before they are committed. This command can be used to add one or more files or to add all changes in a directory.

4. git commit -m "Commit message in quotes" The git commit -m command is used to commit changes to a Git repository. This command takes a message as an argument, which is used to describe the changes being committed.

5. git push The git push command is used to push commits from a local repository to a remote repository. This command can be used to push changes to a remote branch or to a remote repository.

6. git pull The git pull command is used to fetch and download content from a remote repository and update the local repository to match the remote.

7. git branch The git branch command is used to create, list, rename, and delete branches. When you create a new branch, it is based on the current branch. You can also specify a different branch on which to base the new branch. For new branch use: git branch <branch_name>

8. git checkout The git checkout command is used to switch between different branches in a git repository. To create a new branch use: git checkout -b <new_branch>

9. git merge The "git merge" command is used to join two or more development histories together. This is often done in order to combine changes made on separate branches. It can also be used to simply update a single branch with the changes from another.

10. git clone The git clone command is used to create a copy of a specific repository or branch within a repository. This command will get the entire repository - all files, all branches, and all commits.

Practice those commands and make the most of your developing skills! All the Best👍!