TOP GIT Command-Everyone Should Know


TOP GIT Command-Everyone Should Know


Git is a version control system for tracking changes in computer files and coordinating work on those files among multiple people.

It is primarily used for source code management in software development, but it can be used to keep track of changes in any set of files.




Git is an example of a Distributed Version Control System, In Git, every developer's working copy of the code is also a repository that can contain the full history of all changes.

To know more about GIT and the difference between GIT and GITHUB, you can refer to this link.

Refer this link to know about the most common interview questions on GIT.




In this article, we will be learning some of the most useful and commonly use GIT Commands.

Purpose
Git commands
To Configure the username and email to be used with your commits.
git config --global user.name "Ankur Jain"
git config --global user.email ankurjain@gmail.com
To initialize git repository
git init
To create a working copy of a local repository:
git clone /path/to/repository
To Add one or more files to staging (index):
git add <filename>
git add *
git add .
To commit Changes
git commit -m "Commit message"
Push code to the master branch of remote repository
git push origin master
To check git status
git status
To push the code to the remote server
git remote add origin <server>
To get the list of all currently configured remote repositories
git remote -v
To Create and switch to a new branch
git checkout -b <branchname>
To Switch from one branch to another:
git checkout <branchname>
To List all the branches in the repository
git branch
To Delete the particular feature branch:
git branch -d <branchname>
To Push the branch to the remote repository.
git push origin <branchname>
To Push all branches to remote repository:
git push --all origin
To Delete a branch on a remote repository:
git push origin :<branchname>
To merge a branch into an active branch:
git merge <branchname>
To view all the merge conflicts:
View the conflicts against the base file:
Preview changes, before merging:
git diff
git diff --base <filename>
git diff <sourcebranch> <targetbranch>
To get the information about the previous commits to the project.
git log





SHARE THIS

Author:

My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
August 19, 2024 at 4:23 AM

Awesome blogg you have here

Reply
avatar