How to get remote repository and commit files in git

Git commands that are commonly used for managing project files such as ‘init’, ‘add’, ‘commit’, ‘status’, ‘log’.

 386 total views

Git commands

The last Git article illustrates how the git version control system works. This article will help you to learn how to get a remote git repository and commit files in git. You also get knowledge about git basic commands for remote repositories and commit files in git repository as local.

Getting a git repository

To get an existing git repository either from the local system or online repositories such as Github, bitbucket we can use the ‘clone’ command.
The format for getting a repository is as follows

$ git clone 

For example, consider the following syntax

$ git clone https://github.com/example.git

Initializing a repository

Initializing a repository refers to initialize the repository which is needed to be git i.e to be tracked. This is done using the ‘init’ command.To initialize a repository use the following command

$ git init

Go to the folder you need to be tracked and execute the ‘init’ command.
This creates a new file called .git the file that is where the git keeps of the files that are stored in it in the form of encryption.

Next, we need to stage the files that need to be tracked. This is done using ‘add’ command. The staging files refer to set the which files in the repositories are needed to be tracked in the git.
To stage a file

$ git add README.md

Instead of README.md replace with the file name needed to be staged.
To stage all files specify ‘.’ to add all files in the repository.

$ git add .

Next, we need to commit the files that was staged using the ‘commit’ command.

$ git commit

To commit the files we need to specify commit messages for all commits using ‘-m or –message’ specification in ‘commit’ command.

$ git commit -m 'Added new files'

Tracking a repository

To track the file status we can use ‘status’ in the git command.

$ git status

The status will show you the changes that are changed if any as follows.

On branch master
Changes not staged for commit:
    (use "git add ..." to update what will be committed)
    (use "git checkout -- ..." to discard changes in working directory)
        modified:   README.md
no changes added to commit (use "git add" and/or "git commit -a")

If no changes are made in the files it displays the message as follows

On branch master
nothing to commit, working tree clean

To view the log of the files committed to the git we can use the ‘log’ command.
This log command will give you all the logs about the commit done to the files in git.

$ git log

This will output the log as follows

commit 9222b1d10ed1741a2e7ddde50a264a729dc9c85d (HEAD -> master)
Author: AjeethT 
Date:   Thu Jul 16 15:48:54 2020 +0530

The first line gives the commit hash value next it specifies the branch as a master. Next are the author’s name and the timestamp of the commit.

The full flow of the git operation are as follows:

$ git init
$ git add README.md
$ git commit -m 'Initial commit'
$ git status

In the next git post, I will be sharing on different operations on the git repository.
Click here for Git archives.
To view official git documentation please visit git docs.

As I’m new to the blog, I trying to improve the contents daily. Please support it through comments.
If the article is helpful or any thought please comment on me.

 386 total views

Hacker earth solutions

Count divisors – Hacker earth solution. My first hacker earth solution. Count divisors, Factorial, Toggle String, Roy, and Profile Picture-C++.

 290 total views

Count divisors

I try to start practicing for data structures and algorithms. So, I chose this Hacker earth platform to practice my logical skills. This is my first problem with Hacker earth. I first start with the basics of input and output. Here are the hacker earth solutions for count divisors, factorial, toggle string, roy and profile picture using c++.
This problem is called count divisors. This is simple we need to find the count of numbers divisible by a number k.
You can find the problem set from here. The solution for the code is

Factorial

Next is the simple factorial program which gives the factorial of the given number. The problem set is here. The code is below

Toggle string

This probelm is to covert captial letters to small and small letters to capital. This is solved using the ASCII values of the alphabets. The problem set is find here.

Roy and Profile Picture

In this problem, we need to make the profile picture resolution accepted if it is equal or crop it, if it is bigger and upload another if it is small. The problem set is found here.

For programming articles -> Go.

If any suggestions and solutions comment about it, please.

 290 total views

Git and Version control system introduction

Introduction to the git version control tool and basic operations in the git tool.

 360 total views

Git

Git is an open-source version control system used by millions of users over the world. A version control system is used to track every change we do to a project. This system keeps track of every file changes done accordingly to the time. These changes can be rollbacked whenever needed from the repositories. Linus Torvalds, the person who developed the Linux kernel is also the reason to build this Git version control system.

There are three types of version control system

1. Local VCS – In the local version control system, version control is done within the local computer we use. It only saves the changes in the files over time as a version within the local computer. It saves the changes in the localhost.

2. Centralized version control system – Has the name specifies, there is a centralized hub that is used to store the files including the file changes. The central hub stores the file details and the snapshots over time. We can revert the files when needed from the central repository.

3. Distributed version control system – As in the form of distributed computers, we can have a distributed version control system in which the version control system is set on every computer connected over the network. The file changes are distributed over the servers and they can be retrieved at any time.

These repositories can be a local machine or server machine. An opensource distributed Git platform is called GitHub. By this, we can store and control our opensource projects in a distributed manner. This is also helpful in contributing millions of developers over the world for opensource projects successful. The other platforms are called Bitbucket, SourceForge, etc. Among them, Git is popular due to the following features:

  1. Open-source project.
  2. It tracks files like the snapshots in virtual machines.
  3. It gives security by means of checksum all the files using the SHA1 algorithm.
  4. It uses easy strategies to store the files in three stages as stages modified, staged, committed.
Git-working
Working of git

Git installation

Install git on Linux OS

All linux system comes with all the Linux kernel
To install git on Linux distros

Debian system – using apt

sudo apt-get update
sudo apt-get install git

Fedora system – using yum

sudo yum install git

Install git on Windows OS

Like Linux, windows don’t come with git
To install git on windows system

  1. Download the git installer from here.
  2. Select the installer and then give next and setup git first.
  3. Next, we need to configure it by using Command prompt.
  4. Run the following commands in the cmd and give your user_name and email_id

git config --global user.name "user_name"
git config --global user.email "email_id"

Install git on Mac OS

To install git on Mac OS we use brew package manager

Using the brew package manager

brew install git
After successful installation of git check it by checking version using below command
git --version
It will return the following output according to the version number
git version 2.9.2
To get help type
git --help

 360 total views

My new blogsite

Hello everyone, I am Ajeeth Thangarasu admin of developersdoors.xyz. I am a college student and an IT student interested in programming, technology, innovations, environments. I will be posting on things like programming tutorials, technology news, future innovation ideas and news, entertainment news like games, environmental facts, etc. So, please enjoy it, if any thoughts and comments please comment on it. Happy to blog.

 300 total views