31 Git Command: Set Up a GIT Command Locally and it’s Workflow

GIT Commands Workflow

  • GIT was originated by Linus Torvald, the creator or Linux in 2005. These commands are used to develop commercial and non-commercial projects as well as for managing repositories.  
  • It is an open-source version control system (VCS) tool. This tool is designed to handle small to very large projects in the software and Information technology sector to track the changes made in the file. Despite handling all types of projects, GIT commands have maintained its speed and efficiency at the top. In previous days, we used to keep track of the work process to make a copy and changes made in the file. But, after version control is introduced, we can professionally manage our work and folders. Also, it helps in restoring the previous version of project work by storing the last work on GITHUB, its local repository. 
  • A command is a fast & scalable command which provides a highly productive GIT command set to help developers with a high-level operation. Also, providing full access to internals. 
  • A command is also used by software programmers to collaborate on software development and applications. 

Advantages of GIT commands

One of the best benefits/advantages of GIT commands is branching capabilities. GIT branches are cheap to buy and will take hardly any effort to merge. This feature is trendy among every GIT user. The main advantage of these feature branches is to provide an isolated environmental situation for every change in your codebase.

Do You Need to Use a GIT Command?

  • Set up a username and email id in the main configuration file
  • Initialize a GIT repository. This setting will be help user in creating new projects or for existing once
  • We use GIT Commands to copy repository from a remote source and also get the remote reference to the original position and set it over there.
  • Checking your file status that you have changed while working
  • Make changes in your working directory
  • You can save those changes that you don’t want to apply immediately
  • Merge two branches
  • Adding new remote 

How Do You Setup a GIT Command Locally

a. Download GIT Commands

       Install GIT Commands 

b.Check whether GIT command is properly installed in your system. To Verify it, open a new shell and type git — version

c. Now, set up your email address and Id and GIT Username

    Syntax : git config – -global user.name “YOUR_USERNAME”

d. Verify your username

    Syntax: git config – – global user.name

e. Set up your email address

   Syntax git config – global user.email

   [email protected]

f. Verify your email address

    Syntax: git config – -global user.email

The above process is the one-time process as we are using the “global” option. As per project demands, if a developer wants to run this always with a different username and different email id’s then, use the commands without –global option.

Let us view the information you have entered in a project

Synatx: git config -global-list

How Do you Use a GIT?

The Basic flow of using GIT is a s follows:

  • In the root directory or a subdirectory, create a new file.
  • You can update the existing file as well.
  • Add files to the staging area. This addition can be done by using the “git add” command and passing the necessary options.
  • Commit files to the local repository using the “git commit -m <message>” power.
  • Repeat.

Here are some basic GIT commands you need to know:

  • git init: it creates a new local GIT repository. 
  • git clone: It is used to copy a repository from a remote server.
  • git add:  It is used to add files to the staging area. 
  • git commit: It will create a snapshot of the changes and save it to the git directory.
  • git config: It can be used to set user-specific configuration values like email, username, file format, and so on. 
  • git status: It displays the list of changed files together with the files that are yet to be staged or committed.
  • git push: It is used to send local commits to the master branch of the remote repository
  • git checkout: It creates branches and helps you to navigate between them. 
  • git remote: lets you view all remote repositories. The following command will list all connections along with their URLs:
  • git branch: It will list, create, or delete branches. For instance, if you want to list all the branches present in the repository
  • git pull: It merges all the changes present in the remote repository to the local working directory.
  • git merge: It is used to merge a branch into the active one. 
  • git diff: It lists down conflicts. In order to view conflicts against the base file, use
  • tag: marks specific commits. Developers usually use it to mark release points like v1.0 and v2.0.
  • git log: It is used to see the repository’s history by listing certain commit’s details. Running the command will get you an output that looks like this:
    • commit 15f4b6c44b3c8344caasdac9e4be13246e21sad
    • Author: Alex Hunter <[email protected]>
    • Date: Mon Oct 1 12:56:29 2016 -0600
  •  reset: This command will reset the index and the working directory to the last git commit’s state.
  •  git rm: It can be used to remove files from the index and the working directory.
  •  git stash: This command will temporarily save the changes that are not ready to be committed. That way, you can go back to that project later on.
  •  git show: It is a command used to view information about any git object.
  •  git fetch allows users to fetch all objects from the remote repository that don’t currently reside in the local working directory.
  •  git ls-tree: It allows you to view a tree object along with the name, the mode of each item, and the blob’s SHA-1 value. 
  •  git cat-file: It is used to view the type and the size information of a repository object. 
  •  git grep: lets users search through committed trees, working directory, and staging area for specific phrases and words
  •  gitk: shows the graphical interface for a local repository. 
  •  git instaweb: It allows you to browse your local repository in the git-web interface. 
  •  git gc: It will clean unnecessary files and optimize the local repository.
  •  git archive: It lets users create a zip or a tar file containing the constituents of a single repository tree
  •  git prune: It deletes objects that don’t have any incoming pointers.
  •  git fsck: It performs an integrity check of the git file system and identifies any corrupted objects.
  •  git rebase: It is used to apply certain changes from one branch to another. 

 

Leave a Reply