Getting started with Git: made easy

Using GIT from command line in Ubuntu / Linux based OS.

Akhil Mallepally
Geek Culture
3 min readJan 7, 2022

--

https://git-scm.com/images/about/index1@2x.png

In this article, let us clone a remote project and learn basic GIT commands in a GNU/Linux OS.

Ready to dive into typing some commands? Ho! Wait.

Heads up : You need to have some basic setup on your PC/laptop, beforehand.

  • Working Linux Environment.
  • GIT installed(Git is likely to be installed in any Linux based OS, already).

You are here because you already have a github account, at-least I assume so. If not, don’t delay, sign up.

Now that you have GITHUB account setup on your system, let’s go to terminal. CTRL+ALT+T will take you to terminal/konsole.

  1. Search for the GIT version by
    git --version
    You should see git version 2.30.0 (this might be different when you are working on this) on your screen.
    - If GIT is not installed in your local, don’t worry, here it is.
  2. It’s time to configure in your local system.

Note: ‘global’ tells your GitHub to use this information always for anything you do on your Computer.

Good. Now the configuration is done. But how do I check whether it’s done or not? Just try this and see what you get!

3. Cloning part is on the way. It’s very simple.

Tadaa! The project is cloned.

Get into the project folder using cd command.

Note : Try git remote -v and git branch -a, they gives the information about the remote repository and branches respectively.

If you are creating a project folder in local rather than cloning, it is not a git repository. That’s where initializing part comes.

git init

This command instructs git to start to track that folder/directory as a repository.

4. Create, Stage and Commit a file to the cloned repository.

  • Creating an empty file ‘test’ via terminal and write some code or text in the file:
  • To check the changes made/current status of the local repository
  • To add all the file(This is called as staging)
  • Let’s commit these changes

6. We are almost done. The final step to push the code into the original repository is

You should see something like the below if you have cloned the given project or someone else as you should have prior access to that repo as a collaborator. We will discuss about this in our upcoming posts in detail.

remote: Permission to akhilmallepally/programs.git denied to <YOUR_USERNAME>.
fatal: unable to access ‘https://github.com/akhilmallepally/programs.git/’: The requested URL returned error: 403

Below is the pictorial representation of how the above process works. Don’t worry about the commands fetch, checkout, merge as of now, we will discuss them in our next post.

https://greenido.files.wordpress.com/2013/07/git-local-remote.png

This is a elementary idea that you should have when you work on a GIT using commands.

--

--