Home » What is GIT and GIT command

What is GIT and GIT command

git

GIT is a source code management tool which is used to manage changes made on the repository. GIT command is a command line tool that helps in working with the GIT repository.

Git is a free and open source software (FOSS) that helps in managing changes made on a repository. It works by tracking these changes and keeping them safe for future use. The tool uses SHA-1 hashes which are created using an algorithm to uniquely identify each commit or commit message. With the help of this tool, developers can track the history of the commits and roll back to any point in time of such commits if needed.

The git command allows us to use commands from other software such as git, grep, diff and more on any Git repositories we are working with. Git is a command line interface to work with distributed version control software. As Git has become an important tool, it has been adopted by many popular operating systems and development tools including Linux, macOS, and Windows.

Below are common GIT command:

git config

$ git config --global user.name "Acil Technologies"
$ git config --global user.email acilsoftware@gmail.com

Git config is a configuration file for git. It contains most of the settings for your project. The file is usually located at .git/config in your home directory. But you can also specify an alternate location for the file by adding a line to the [core] section of your .gitconfig file.

git init

git init

The git init command, which specifies the initial state of a new repository, The git init command will create a new repository on the remote server. You can call it whatever you want, but make sure that you create a README in the root directory or provide some instructions for future contributors.

git clone

git clone URL_PATH

There are two main purposes for implementing git clone: for sharing files and for synchronization.

First, if you want to share a file or a folder across computers and/or devices, you can use the git clone command to synchronize the files on multiple computers. Second, if you are working in multiple projects, you can use the git clone command to push all of your project’s code onto a central server and then pull it down onto your local computer when you need it.

git add

git add

Git add is a command in Git that adds a new file to the current working directory. The git add command is used to add files to the working tree. The files will be added to your staging area, and then you can commit them. The git add command is not a commit step, as it does not alter your repository’s history. It simply adds new content to the staging area without making any changes in your repository’s commits and without running any tests or tests on those changes.

git commit

git commit -m "CHANGES_NAME"

The git commit command manages the files in your repository, allows you to make changes, and then stores these changes in a new commit on the branch. The result of this operation is usually a new commit object which provides a record of the changes made.

git diff

git diff

The Git diff command is used to show the differences between two files in a git repository. The output of git diff will be an ASCII text representation of the differences made by Git, along with any additional information such as line numbers and commit ids.

git reset

git reset --hard

A git reset is a command that suspends the current state of the repository and rewires it to an earlier point in time.

A git reset can be helpful in cases where you want to undo previous mistakes or when you are trying to recover from a failed merge. Resets are one of the most powerful ways to commit many small changes at once, but should be used sparingly because they can have unintended consequences such as creating a false sense of progress on your project.

git status

git status

The git status command is useful for finding out whether your changes have been made successfully or not. If you are unsure, use git diff to get a detailed view of your changes.

Git status [file] shows the current state of files in a Git repository. It’s most often used before committing changes for certain files or directories, but it can also be used before pushing commits to GitHub and other repositories.

git rm

git rm FILE_NAME

Git rm is a command that removes a file from a Git repository. If you would like to remove all files from your current branch, you would run “git branch -D” followed by “git rm.”

git log

git log

Git log, also known as git history, is a list of changes made to the project’s files. The log contains information about who made the changes and when they were made.

The git log shows all the changes that were made to the repository since it was created and allows us to see our progress over time.

git show

Git show generally shows the differences in changes, additions and deletions between two versions of a file or directory. In other words, it displays the differences on a single text file. The changes can be shown in one of two ways: as an annotated text version that contains comments about each change and an unannotated version that only has the filename and line number for each change.

git tag

Git tags are often used as markers of specific changes to be made in the project’s code and are typically referred to as “version identifiers.”

The most common tags are major releases, but tags can also be used to track different milestones (e.g. “0.1”, “v1”, “alpha”).

The git command for adding and examining git tags is git tag -l, which lists all the existing tags on your system.

git branch

Git Branch is a name given to the set of commits that are related to one another. In Git, the term branch is used to represent work that has not yet been merged into a parent branch.

A commit can be thought of as a snapshot of your project’s state at that point in time. When you make changes to it, you create a new commit.

The main advantage of using Git Branch is that when you are finished with your work and want to share it with others, your changes are already housed in their own branch which allows them to easily get started on the same file without having to merge their branches together.

git checkout

git checkout

The git checkout command deletes the working tree, including all changes made in it, and does not record which files have been changed, nor does it save any history for those changes.

git merge

git merge

Git merges are a common way to combine two or more branches into a single branch. It is recommended to use git merge instead of switch when your branch is based on a remote branch and you want to keep the remote branch history.

The Git Merge process can be achieved with the help of the following five steps:

  • Create a new branch on the remote repository (the location in which changes are made)
  • Make all the changes you want to have merged
  • Commit and push your changes
  • Pull new branches from their corresponding remote repositories
  • Merge your newly created branch with the original one

git remote

git remote

Git remote is a Git command that can be used to create a new remote repository on the local host.

git push

git push

A git push is the process of updating a branch with changes from another branch or commit. In other words, it’s the act of sending new commits to a repository.

git pull

git pull

The git pull command is used to update a local repository and the remote repository with the most recent changes from the remote repository. This can be done locally or remotely.

 git stash

git stash

The git stash command can be used to store the current changes for later use. It can help you to recover the lost work, do an undo and save the work in a different branch without committing all of it or saving it permanently.

Related Blogs