Hello All, Today we will see the Top 11 Important Git Commands. These commands are widely used while you are working with Git. Also, We will discuss Steps to Push the code using Visual Studio Code.
So, Let’s Start…
In this topic, We will cover the following commands
Table of Contents
List Of Top 11 Important Git Commands
- Clone Git Project
- Configure Git Email
- Check whether Git Email is Saved Or Not
- Configure Git UserName
- Check whether Git UserName is Saved Or Not
- Pull Command
- Create new branch
- Add Files
- Commit Changes
- Push
- Switch Branch
Clone Git Project
git clone <address>
Configure Git Email
git config user.email "<email>"
Check whether Git Email is Saved Or Not
git config user.email
Configure Git UserName
git config user.name "<name>"
Check whether Git UserName is Saved Or Not
git config user.name
Pull Command
git pull origin <branchname>
Create New Branch
git checkout -b <branchname>
Add Files
git add .
Commit Changes
git commit -m "<MESSAGE>"
Push Command
git push origin <branchname>
Switch Branch
git checkout master
OR
git fetch
git checkout master
Steps to Push the code to Git using Visual Studio Code
If you are using Visual Studio Code then you might not need to write every command as Visual Studio Code itself gives more options which will make things easier.
Follow the below steps if you are using visual studio code
- Open Visual Studio Code
- git clone <address> : To Clone the Project
- git pull origin <branchname> : To get Latest code from branch
- git checkout -b <branchname> : To create a new branch
- Make the changes in the code
- Click on Source Control Icon from the left menu
- Click on + ( Stage change ): Click on the + icon for every file which you want to push
- Write commit message ( Placeholder: Message )
- Click on the commit icon
- Click Push from …(Views and More Actions…)
- Go to the portal & create a pull request