DEV Community

Sifat Faysal
Sifat Faysal

Posted on • Updated on

Basic git setup on Ubuntu

Git is a powerful and widely-used version control system that allows developers to easily track changes in their code and collaborate with others on software projects.

When you install Git on your computer, you'll be able to use it to track changes in your code and collaborate with others. Here's a step-by-step guide on how to install Git on Ubuntu:

  1. Open a terminal window by pressing Ctrl+Alt+T
  2. Update the package manager by running the command sudo apt-get update
  3. Install Git by running the command sudo apt-get install git
  4. Verify the installation by running git --version. This should display the version of Git that was installed.

Now that Git is installed, you'll need to set up your personal information so that it is included in the commits you make. This is done by running the following commands:

git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
Enter fullscreen mode Exit fullscreen mode

You can also set your preferred text editor for Git by running:

git config --global core.editor <editor>
Enter fullscreen mode Exit fullscreen mode

With Git all set up, you can now start using it to track changes in your code. For example, you can create a new repository in an existing directory by running the command git init.

Now, in order to connect to a remote repository using git, you can use SSH key. The process of generating SSH key is as follows:

  1. Open a terminal window and run the command ssh-keygen
  2. Press enter to confirm the default location and name of the key file
  3. Then it prompts you to enter a passphrase, this is optional, but it is better to set it
  4. This will create two files id_rsa(private key) and id_rsa.pub(public key) in the .ssh directory in your home folder
  5. Now you need to copy the content of the public key by running cat ~/.ssh/id_rsa.pub
  6. Go to your remote git service provider (e.g GitHub, GitLab) and add the copied key to your profile

Now, you should be able to use Git to track changes in your code, collaborate with others, and contribute to open source projects. Keep in mind that this is just a brief introduction to the basics of Git and there is much more to learn as you start using it in your own projects.

Top comments (0)