Skip to main content

Top Git Commands Every Developer Should Know and must know


        Git is a free and open-source distributed version control system for tracking changes in any set of files, usually used for coordinating work from small to very large projects with speed and effectiveness. With it, we can know who did what, when, and why. Nowadays, Git has become a must-have tool for any developer, programmer, graphical designer, and many other mores. Knowing Git commands is essential for developers to use Git to its Full Potential. Enlisting hundreds of Git commands, but only a few significant commands are used regularly. In this article, I will explain the commands that I usually used the most for the next level development. 

       In this article, I will explain the commands that I usually used the most for the next level development.

#1 git init

        This git command will let you create a new repository. It can be used to convert an existing, un-versioned project to a Git repository or initialize a new, empty repository. This is usually the first command you'll run in a new project. But you can’t see the Init file in your project folder, it’s remained hidden.

            Example:

$ git init

#2 git status

            This git command will display the state of the working directory and the staging area. It lets you see either your file is either your file is in staged or not, which file aren’t being tracked but Git. Shortly Git provides an overview of the current status of your repository.

          Example:

$ git status

#3 git add

        This Git commands let’s us add a branch to an existing master branch , viewing all existing branches, and delete a branch. There’s already a master(main) branch in your project.

        Example:

$ git add <file-name>

or

git add .

#4 git branch:

        This Git commands let’s us add a branch to an existing master branch , viewing all existing branches, and delete a branch. There’s already a master(main) branch in your project.

        Example:

$ git branch <branch-name>

or

$ git branch a

or

$ git branch or git branch --list

or

$ git branch -d <branch-name>

or

$ git branch -m <branch-name><new-branch-name>

#5 git checkout

        This git command allows us to switch to an existing branch to next branch.

        Example:

$ git checkout <branch-name>

or

$ git checkout -b <new-branch-name>

#6 git commit:

        Every time you commit your code, you have to include a brief description of the change made. Before pushing to repository and after add the file to staging are this command is usually used. This commit message helps others understand the changes that have been done.

        Example:

$ git commit -a

or

$ git commit -m “<Msg>”

or

$ git commit -am “<Msg>”

or

$ git commit –amend -m “<Msg>”


#6 git push:

        This git command push the local file change to the remote repository. It also creates a branch automatically names as a Master branch if any branch doesn’t exist.

        Example:

$ git push or $ git push <remote> <branch-name>

or

$ git push origin master.


#7 git pull:

        This git command achieves the last uploaded changes from the remote server to the local repository to get the latest updates of the remote repository.

        Example:

$ git pull or $ git pull origin master


#8 git merge:

        This git command merges your created or added branches with the master branches. It lets you take the independent lines of development created by git branch and integrate them into a single branch.

        Example:

$ git merge <branch-name>


#9 git diff:

        This git command Show changes between commits, commit and working tree, etc. Mainly I used to see the either I forget to upload any changes to repository. 

        Example:

$ git diff --staged


#10 git reset:

        Git reset is a powerful command that is used to undo local changes to the state of a Git repo. It will undo the last change you have done on git repo.

        Example:

$ git reset hard


#11 git log:

       Git log command shows a list of all the commits made to a repository.

        Example:

$ git log

or

$ git log --oneline


#12 git clone:

       Git log command shows a list of all the commits made to a repository.

        Example:

$ git clone https://github.com/devrajKhadka-smiley/Git_code.git

Comments

Popular posts from this blog

Installing Pyrit on Kali linux

        Pyrit is one of the most powerful WPA/WPA2 cracking tools in a hacker's arsenal, with the ability to benchmark a computer's CPU speeds, analyze captures files for crackable handshakes, and even tap to GPU password-cracking power.                                        Pyrit allows you to create a massive database of the Pre-computed WPA/WPA2-PSK authentication phase in a space-time tradeoff. Sometimes it gets tough for someone (as for me while I was a beginner it was pretty hard for me to install to know about it). you have to clone the pyrit from https://github.com/JPaulMora/Pyrit.git . let's open the terminal and get started.         I will always recommend every user to use the terminal on root on installing or downloading. To get into root user just type " Sudo su " on your terminal. sudo su apt-get install libp...

Snaps do not appear in the dash/menu on gnome (Kali-Linux)

           while I recently install the new kali Linux 2021.4 everything was going good but unfortunately, while installing the desktop application through snap, it was not showing in the dash/menu on gnome. Well, i tried enough few methods I were familiar to like,:  systemctl enable --now snapd apparmor emulate sh -c 'source /etc/profile'     Well after trying " emulate sh -C'source/etc/profile ' command I had to face a profile on my local device. It doesn't allow my machine to open any applications, I mean I wasn't able to open any of the applications. while I try to open any application it doesn't do anything. I was clueless about what to do next and reinstall my Linux os. But any of the methods doesn't work for me, was so depressed about it and while I mistakenly went to the .local folder and Application folder inside of the shared folder there was nothing ( i mean the blank folder). So I decided to extract the snap install application to...

How to Install Android Studio on Kali Linux - 2021.2

Android studio is the official integrated development environment for Google's Android operating system build through JetBrains' IntelliJ IDEA  Software and designed specified for Android development to accelerate the development and help to build the highest-quality apps for the every Android Devices.                    To use this software you need to know Java and have to installed on your desktop. In my case (Linux), system recommendation is:       GNOME or KDE or Unity desktop 2 GB RAM minimum, 4 GB RAM recommended 400 MB hard disk space plus at least 1 GB  Oracle Java Development Kit (JDK) 7     To install Android studio on Kali Linux or any Ubuntu version or distribution you need to install Snapd or Snap(Snap is a software packaging and deployment system developed by Canonical for Operating System that use the Linux kernal.)                ...