How to Use Git commands on Linux Terminals
Speaking of Git, developers are not familiar with it. before using it, we need to understand several issues:
What is Git?
If you are a software developer, you must be familiar with Git. Git greatly facilitates developers to control the source code version or version of software development. This is a distributed version control system. GIT provides better speed and data integrity than SVN, and supports non-linear workflows. Git was initially designed for Linux kernel development by Linus Torvalds. Linus Torvalds is the creator of Linux kernel design and Git. GIT was initially designed for developers from around the world to update the Linux kernel source code. In any other version control system, each Git working directory has a complete history and full-version tracking capability, providing a comprehensive information library. Git distributes free software under the terms of the GNU General Public License.
How does Git run?
Git processes data more like a group of snapshots, snapshots of small file systems. Each state of a project submitted by you or saved in the Git project library requires a snapshot. Therefore, it saves a reference to make all files look like snapshots submitted at that moment. To improve efficiency, speed, and accuracy, if the file remains unchanged, Git will not save the file again unless your submission has further changes. It simply stores the link to it and has stored the same file as before.
It is used to process 100,000 of large file projects. Git is mainly developed for Linux. It now supports most mainstream operating systems, including BSD, Solaris, OS X, and even Microsoft Windows.
How to Use Git?
There are many different ways to use git. Most of the time, we use the command line tool, of course, there must be a lot of graphical user interface (GUI) software. I will use the Git command line on the terminal. You can run all Git commands in the terminal by using the command line. the graphical user interface of the Git tool can only use basic functions.
How to install Git?
Most Linux distributions are pre-installed with Git. However, you may need to install the latest version. For RedHat/CentOS/Fedora, run the following command to install it on the terminal:
Sudo yum install git
If you are releasing a Debian-based version like Ubuntu, try the following command to install it:
Sudo apt-get install git
Use the following command to install openSUSE:
Zypper install git-core git
For more releases, click here to view the installation instructions.
Create your identity information
First, you need to set your username and email address for GIT:
Git config -- global user. name "Mf Iftekher"
Git config -- global user. email xyz@xyz.com
Check your Git settings
Check your Git settings and run the following command on the terminal.
Git config -- list
Clone a git Repository
First, you must start cloning the Git repository for your project. Only you can submit your modifications.
Git clone https://gitlab.com/xyz/abc.git
The above command is how to clone the Git repository of the server. In this example, the Git repository server gitlab and abc. git are used as the names. You can use Git to host the server or the server's FQDN, Git IP address.
Initialize a new Git Repository
If you want to start a Git repository server for your code library, use the following command:
Git init
This will start a new Git repository and machine/host which can now be used as a specific code repository server. You can access the newly created repository by using the Host IP address or host name.
Check the Git status:
Git status
Add a new File Repository
Let's add a file to your newly created git repository. Create a demo file and run the following command:
Vim demo.txt
Add the newly created file through the index of the released git Repository:
Git add demo.txt
Now, we need to use your git Repository
Git commit-m'first commit'
Add content and comments to the demo.txt file and submit it.
Vim demo.txt
Add the following content to the file.
This is a demo file. This is the second line of the file. This is the third line.
Git commit-m'second commit'
This will update the file accordingly.
Now, push the changes to the repository.
Git push
This will promote this transition to the master branch.
Delete files from Git
You can delete the documentation.txt file only after one click.
Git rm documentation.txt
Git commit-m "documentation.txt file removed"
Git push
Reset GIT
If you want to reset your index and working directory to the status of your last commit or any commit, the terminal executes the following command:
Git reset -- hard commit number/HEAD
Git Storage
You have changed some files but do not want to submit them. You can temporarily store them and submit them later:
Sudo git stash
Get Git
If you want to synchronize your local git code library with the latest code library of the Git Remote Server repository, you need to use the following command.
Git pull
View log files
If you want to see a master branch submission list that contains the log details, enter:
Git log
Check Git Branch
The Git repository can contain master branches and multiple branches. You want to know your git branch, terminal input:
Git branch
The above is just a basic GIT command, and I hope you will like it!
Git Tutorials:
GitHub tutorials
Git tag management details
Git branch management
Git remote repository details
Git local Repository (Repository) Details
Git server setup and Client installation
Git Overview
Share practical GitHub tutorials
How to Build and use Git servers in Ubuntu
Git details: click here
Git: click here
This article permanently updates the link address: