What is Git?
Git is open-source version control. It allows users to collaboratively developing source code during development.
Git helps to track file & files changes in your project directory.
Download & install :
Linux/Unix : https://git-scm.com/download/linux
Mac : https://git-scm.com/download/mac
Windows : https://git-scm.com/download/win
Let see the Git commands that every developer should know :
1) Initialize & Clone
git init : Create an empty Git repository in the current directory.
Example : git init
To Create an empty git repository in a specified directory.
Example : git int <directory-name> => git init todo-app
git clone : retrieve and clone existing project repository from the cloud by using git repository URL
Example : git clone <repo-url>
git clone https://github.com/flutter/flutter.git
2) Git Config
- Git Config command helps to store information like email, username, etc in local machine.
- This git configuration helps to find the changes that you made in the local machine.
Example :
git config --global user.name "user-name"
git config --global user.email "user-email"
3) Git Remote
- Git remote command helps to manage your git repository URL in your projects.
git remote add : Add a new remote
Example : git remote add <remote-name> "<repo-url>"
git remote add origin "https://github.com/flutter/flutter.git"
git remote rm : Remove existing remote
Example : git remote rm <remote-name> => git remote rm origin
git remote set-url : To change or update remote URL
Example : git remote set-url <remote-name> "<repo-url>"
git remote set-url origin "https://github.com/flutter/flutter.git"
Git remote verify : List the available remotes
Example : git remote -v
4) Git Branch & Checkout
- Git Branch helps to manage your project source code in different versions and git branches are isolated.
- Git branch commands help to manage your branches.
git branch : This command helps to list the available branches in your project repository.
git branch <name> : This command helps to list the available branches in your project repository.
Example : git branch <branch-name> => git branch development
git checkout : This command helps to switch between two or more existing branches in your repository.
Example : git checkout <branch-name> => git checkout develop
If you want to create and checkout to new branch
Example : git checkout -b <branch-name> => git checkout -b develop
Above command create new branch with given name and checkout to new branch.
5) Git Basic
git pull : This command helps to fetch the latest updated changes from the specific or master branch.
Note: Mostly remote names will be an origin
Example :
git pull <remote-name> <branch-name> => git pull origin develop
git add : This command helps to stage all changes to the next commit.
You can add the single & multiple modified files to the repository.
Stage single or specific file .
Example : git add <filename> => git add attractiveaurora.html
Stage all modified files. .
Example : git add *
git status : helps to find the staged and unstaged files in the repository.
git commit : take a snapshot of staged changes with the message.
Example :
git commit -m "<message>" => git commit -m "new feature added"
git push : send the snapshot of changes to the specific branch.
Example :
git push <remote-name> <branch-name> => git push origin develop
I think this information is helpful to you.
Thanks for reading - Don't Forgot To Share & Comment
Any suggestion or queries please comment, our team will response asps.
You may like this :
Best Visual Studio Code Extensions - Part 9
Best Visual Studio Code Extensions - Part 8
Best Visual Studio Code Extensions - Part 7
Best Visual Studio Code Extensions - Part 6
Best Visual Studio Code Extensions - Part 5
Best Visual Studio Code Extensions - Part 4
Best Visual Studio Code Extensions - Part 3
Best Visual Studio Code Extensions - Part 2
Best Visual Studio Code Extensions - Part 1
Best IDE / Editor Web Development
Best 5 Angular UI component library
Why JavaScript most popular ?