• Ubuntu
  • Python
  • Windows
  • VirtualBox
  • Git
  • Docker
  • Windows
Chat
Writy.
No Result
View All Result
My Account
Writy.
No Result
View All Result
sxi
No Result
View All Result

Home Installing and Getting Started with Git on Debian 10

Installing and Getting Started with Git on Debian 10

SXI ADMIN by SXI ADMIN
February 13, 2020
in Git
Reading Time: 7 mins read
A A
0
Share on FacebookShare on Twitter
Git is a very popular Version Control System (VCS). It is used to track changes in source codes during software development. It is a really helpful tool for rapid software development. Git is very fast at doing its job. It is one of the best tools a developer can have if utilized properly. Git is totally open source.

In this article, I am going to show you how to install Git on Debian 10 Buster and how to get started with Git. So, let’s get started.

Installing Git:

Git is available in the official package repository of Debian 10. So, you can easily install Git on Debian 10 using the APT package manager.

First, updae the APT package repository cache with the following command:

$ sudo apt update

The APT package repository cache should be updated.

Now, install Git from the official Debian 10 package repository with the following command:

$ sudo apt install git

Now, press Y and then press <Enter> to confirm the installation.

APT should download and install all the required packages.

At this point, Git should be installed.

Once Git is installed, check whether Git is working with the following command:

$ git –version

As you can see, I am running Git 2.20.1 on my Debian 10 machine. It’s working correctly.

Setting Up Global Git Username and Email:

The first thing you should do after installing Git is to set up a global Git username and email. This username and email will be used in your Git repositories by default.

To set up a global Git username, run the following command:

$ git config –global user.name "YOUR_NAME"

NOTE: Replace YOUR_NAME with your own name.

To set up a global Git email, run the following command:

$ git config –global user.email "YOUR_EMAIL"

NOTE: Replace YOUR_EMAIL with your own email address.

Now, check whether the global username and email is set with the following command:

$ git config –global -l

As you can see, the global user.name and user.email is correctly set.

Git Terms:

In order to understand Git, you should be familiar with some of the common Git terms.

Repository: It is a directory on your local computer or a remote server where all your project files are kept and tracked by Git.

Untracked: If you create a new file on your Git repository, then it is called an untracked file in Git. Unless you tell git to track it, Git won’t track a file.

Tracked: If you want Git to track a file, then you have to tell Git to track the file manually.

Staged: Before you commit your changes to the Git repository, you must add the files to the staging area. The files in the staging area is called staged files.

Modified: If you add a file in the staging area, and modify the file again before committing, then the file will have a modified status. You will have to add the file to the staging area again for you to be able to commit it.

Commit: It is keeping a snapshot of the files that are in the staging area. A commit has information such as a title, description, author name, email, hash etc.

Basic Git Workflow:

In this section, I am going to show you the basic Git workflow. I am going to create a new Git repository on my local filesystem, and start developing a simple Node.js project on that repository and use Git to track changes in my project. So, let’s get started.

First, make a new project directory hello-node/ and navigate to the project directory with the following commands:

$ mkdir hello-node
$ cd hello-node/

Now, initialize a new Git repository in the project directory with the following command:

$ git init

As you can see, a new empty Git repository is initialized.

Now, create a new file hello.js and type in the following lines of code in it.

console.log(“Hello from LinuxHint!”);

Now, to see the status of the files in the Git repository, run the following command:

$ git status

As you can see, the file hello.js is marked red. Which means it’s an untracked file.

Now, to track the file hello.js, run the following command:

$ git add hello.js

NOTE: If you have a lot of files in your project directory that you want to track, then you don’t have to run git add for each of the files. Instead you can run the following command to track them all.

$ git add .

Now, check the status of the files with the following command:

$ git status

As you can see, the file is now marked green, which means Git is tracking the file and the file is staged. It’s ready to be committed.

Now, to commit the changes, run the following command:

$ git commit

A text editor should be opened. Now, type in a commit message. It could be anything. But it should help you remember what you did here. Ignore the lines starting with #. These are comments and won’t be added to the actual commit.

Once you’ve written the commit message, press <Ctrl> + X followed by Y and <Enter> to save the file.

The changes should be committed.

You can list all the existing commits with the following command:

$ git log –oneline

As you can see, the commit I’ve added is listed here. Each commit has its own hash and the hash is unique throughout the project. In this particular commit, the hash is 1edc2d2. This is the short form of the hash. It is enough to uniquely identify each commits.

If you want to see the long form of the hash, then list the existing commits with the following command:

$ git log

As you can see, more information about each commit is listed. Also, the hash is printed in the long form.

You can further modify existing files, add new files, track them, stage them, add new commits and so on to develop your project.

So, that’s how you install Git on Debian 10 Buster and get started with Git on Debian 10. Thanks for reading this article.

Total
0
Shares
Share 0
Tweet 0
Pin it 0
Share 0
SXI ADMIN

SXI ADMIN

Related Stories

Configure Git Server with SSH on CentOS 8

Configure Git Server with SSH on CentOS 8

by SXI ADMIN
February 13, 2020
0

If you have a small tech company, you can set up an SSH based Git server so that the people...

Configure Git Server with HTTP on CentOS 8

Configure Git Server with HTTP on CentOS 8

by SXI ADMIN
February 13, 2020
0

In this article, I am going to show you how to configure Git Smart HTTP server on CentOS 8 for...

5 Best Self-hosted GitHub Alternatives

5 Best Self-hosted GitHub Alternatives

by SXI ADMIN
February 13, 2020
0

GitHub may be the most popular computer code hosting service for version control using Git, which is a distributed version...

How to Create Branches on Git

How to Create Branches on Git

by SXI ADMIN
February 13, 2020
0

Git is one of the best version control system out there. It is very popular among almost every type of...

How to Delete Remote Branch in Git

How to Delete Remote Branch in Git

by SXI ADMIN
February 13, 2020
0

In this article, I am going to show you how to delete or remove a remote Git branch. I will...

Git – Push Changes to Remote Git Branch

Git – Push Changes to Remote Git Branch

by SXI ADMIN
February 13, 2020
0

In this article, I am going to show you how to push (upload) your local Git repository to a remote...

Load More
Next Post
Install MongoDB 4 on Debian 10

Install MongoDB 4 on Debian 10

Popular Story

  • EMEDITOR PROFESSIONAL Full Key V11~V19

    645 shares
    Share 258 Tweet 161
  • Plesk Obsidian Lifetime license Key Version 18.0.15

    644 shares
    Share 258 Tweet 161
  • Plesk Onyx + Obsidian 18 Web Host Edition Nulled/Crack

    614 shares
    Share 246 Tweet 154
  • How To Start/Stop/Restart Cron Service In Linux Centos 7

    610 shares
    Share 244 Tweet 153
  • Download Windows Templates for Virtualizor KVM Windows server 2008,2012,2016,2019

    608 shares
    Share 243 Tweet 152
SXI.IO

© 2022 Vps giá rẻ

Navigate Site

  • Ubuntu
  • Python
  • Windows
  • VirtualBox
  • Git
  • Docker
  • Windows

Follow Us

No Result
View All Result
  • Ubuntu
  • Python
  • Windows
  • VirtualBox
  • Git
  • Docker
  • Windows

© 2022 Vps giá rẻ