Git: Basic commands

Photo by Yancy Min on Unsplash

Git: Basic commands

Part-1

What is Git

  • Git is a version control system.
  • It is open source.
  • It is used to collaborate between the team
  • It uses to track the changes like what changes are made, its history including who has done the changes.

Download the Git

Below is the link where you can download the git. You can download it for any OS.

Download Git

  • Windows - Installer can be downloaded.
  • Mac - Homebrew can be used.

Screenshot 2022-07-23 at 9.56.26 PM.png

Basic Commands

1. Git Config

  • Git configurations need to be added first when you start using it.
  • User Name and User email address(linked to repository hosting platform) will be used when you does the commits.

Add User Name

 git config --global user.name "Laxmi Nimbalkar"

Add User Email

 git config --global user.email "abcd@gmail.com"

2. Git Init

Initialise the repository

 git init

3. Git Status

This command helps us to get the status of the git in current repository. It give us details of branch we are on and also the list of tracked and untracked files.

 git status

4. Git Add

This command helps us to add tracked and untracked files to the staging environment. Basically we stage the files which needs to be pushed.

Staging environment is that environment where we give the confirmation on the files which needs to be pushed to repository

Add specific files.

 git add one.js two.js

Add all files. (Dot operator)

 git add .

5. Git Commit

This command is used once you stage the files and these files needs to committed giving the message about what specific changes does.

 git commit -m "Adding new files"

6. Git Push

This command is used to push the changes i.e to push your committed files to your remote repository.

 git push origin <branch_name>

Conclusion

This blog just covers the basic git commands. In future next part will be released. Please wait for the update.