ttmind

Main Navigation

ttmind
  • jim-jams
  • Tech
  • Positive
Login

Login

Facebook Google

OR

Remember me Forgot password?

Don't have account? Signup here.

Sort by Categorys

.Net

PHP

Java

JavaScript

Database

Server

Client Side

Tools

Artificial Intelligence

Cloud

Hybrid Development

Event

Smart City

Education

Security

Scrum

Digital Marketing

APP Development

Business

Internet

Simulation

Art

Network

Microservices

Architecture

Technology

Leadership

    Top Articles

  • How Does Social Media Bring People Together?
    TTMind Author
  • How to read appSettings JSON from Class Library in ASP.NET Core
    Anil Shrestha
  • Printing Support In Asp.Net Core
    TTMind Author
  • HOW TO EXTRACT TEXT FROM IMAGE USING JAVASCRIPT (OCR with Tesseract.js)?
    Prakash Pokhrel
  • Images Upload REST API using ASP.NET Core
    Prakash Pokhrel
  • Related Topic

  • How to code quicker with code snippets in Visual Studio 2019
  • How to Fix Error Failed to create directory In Android SDK Not Downloading Packages?
  • What’s new in visual studio 2019?
  • How to access Visual studio wep app using Conveyor Cloud services?
  • Introduction to SQL Server Management Studio(SSMS)
  • Tech
  • About Us
  • Contact Us
  • TechHelp
  • PositiveHelp
  • Jim-Jams Help
  • Terms & Conditions

© Copyright ttmind.com

Main Content

Git Commands you must know

Tools Git about 7 years ago || 4/23/2019 || 4.5 K View

  • Hide

Git Commands you must know:

Developed by Linus Torvalds in 2005, Git is a Version Control Appication which is very much popular among the developers. Though there are many version control applications. Git is one of the most popular and most used one. The real importance of git is that it is extremely light weighted while still being highly robust and flexible. Furthermore, it is completely distributed and doesn’t need any central server system. Also, it doesn’t even need network connectivity, you can use it in self-contained manner in your own device. So, it’s not a surprise about it being the predominant VCS in the workplace.

So, having some knowledge and skills for using git is a must if you are a developer.

Below we have some basic commands that are required for your day to day operation.

- git config:

one of the most used command, it is used for setting user configuration attributes like email, username, file format, etc

For example for setting email we have the command:

git config --global user.email abc@gmail.com

- git init:

This command is used for creating new GIT repository.

use: git init

- git status:

This command is used for checking the list of files changed along with the files that needs to be added or commited.

- git log:

Using git log we can study and get details of the repository history

For eg in order to see only the commits of certain author

git log –author=Anil

- git add:

This command is used for adding new files to the index. For example lets add a file named home.html form local directory to index.

git add home.html

- git commit:

This command is used for committing the changes to the head. Committed changes does not make it to the remote repository yet .

git commit –m “Message about the changes”

- git push:

Another most used commands that transfers the changes to the master branch of the remote repository associated with the working directory. You can change the master to whatever branch you are willing to make the change

git push origin master

- git pull:

This commands is also the most used one which lets us merge all the changes to our local working directory. Updating the local repository to the newest commit

git pull

- git merge:

This command is used for merging a branch into our active branch (eg master). Use

git merge <branch-name>

- git reset:

In order to reset the working directory to the previously committed state

git reset – hard HEAD

- Creating shortcuts in git:

We may get bored typing long git syntax time after time. To get over it we can create shortcuts. First we need git bash editor which leads us to the home directory. There you can find and edit your .bash_profile file where we can add the shortcuts . It can be done by adding text as

alias gc=’git commit’

alias gr=’git revert’

- Storing Username and Password in git:

Some us have come across a situation where we need to repeatedly enter the user credentials while executing the push, pull and commit commands. Mostly happens when we use Tortoise Git

We can solve it by following steps

  • Navigate to the root directory thrugh CMD
  • Enter git config credential.helper store then,
  • Pull the repo with git pull

There you are asked for username and password, once provided the credentials are stored and not asked repeatedly.

- Branching in git:

Branches are used for developing features isolated from each other.

 When creating a repository Master Branch is the default branch. We can create other ranches for development and collaborate them back to the master repo.

Lets create a new branch named “Dashboard”

Git checkout –b feature_x

Switch back to master

git checkout master

Deleting the branch

git branch –d feature_x

The branch is not available to other until we push the branch to the remote repository using

Git push origin <branch>

This are some of the most commonly used git commands but we also have a sheet containing all of these commands that may be useful for you.

Follow the link : Git Command Sheet

Also Read: Programming Languages to learn in 2019

 

 

  • 0
  • 0
  • 0
    • Facebook
    • Twitter
    • Google +
    • LinkedIn

About author

Binod  Bhandari

Binod Bhandari

Life is not just about thrieving but all about living.

Reset Your Password
Enter your email address that you used to register. We'll send you an email with your username and a link to reset your password.

Quick Survey