🎗️Concepts to know in GIT & GITHUB 🦋

🎗️Concepts to know in GIT & GITHUB 🦋

In the previous article we already understand the basics of GIT & GITHUB, Now we will be going deeper into more advanced concepts of GIT & GITHUB. Let' s begin.

As we know GIT is an open source, distributed version control systyem and GITHUB is a platform for hosting and collaborating with people on GIT repositories. Let's have a look at the diffrence between GIT & GITHUB.

🎯What is the difference between GIT & GITHUB ?

GITGITHUB
1. GIT is software tool managed by LINUX.1. GITHUB is a service owned by Microsoft.
2. GIT is distributed version control system used to maintain and manage the changes in files.2.GITHUB is a web hosting platform for collaborations, code sharing, and access to Git repositories.
3.GIT operates locally on your computer.3. GITHUB is a web based platform.
4. GIT is a open sourced4. GITHUB includes a free tier and pay-for-use-tier

🎯Terms in GIT:-

Repository :

  • Its a kind of folder where you have all your codes.

  • its a place where you store the files, documents, code base, folders and other related stuffs of projects.

    There are two types of repository;

    1. Local Repository : as the name suggests local means "local to you" which means the repository is located on your machine.

  • When you clone the remote repository, the exact copy of the repository get created in your machine, where you can make changes, commit changes and create branches and push the changes.

    2. Remote Repository : here the repository is located on some server which can be accessed and shared over the internet. It allows multiple peoples to collaborate, works on same codebase and track the versions.

Tags :

tags assign a meaningful name with a specific version in the repository. once a tag is created for a particular codebase even if you create a new commit, it will not be updated.

Snapshots:

Represents data of particular time. Its stores the changes only not a entire copy.

commits:

a GIT object, snapshot of your entire repository compressed into a SHA. Basically it store the changes in repository and will get one commit_ID for each change.

Clone:

a local version of a repository, including all commits and branches using GIT. Changes made to the cloned repository cannot be merged with the original repository unless you are the collaborator or the owner of the repository.

Fork:

creating a copy of the original repository on our GitHub account. Changes made to the forked repository can be merged with the original repository via a pull request.

Pull Requests:

its an event that discuss the changes introduced on a branch with reviews, comments, integrated tests .etc to another branch in GIT repository.

HEAD :

representing your current working directory, the HEAD pointer can be moved to diffrent branches,tags or commits when using git cloudwatch.

🎯How to use GIT commands???

1. Configure tooling

If a user is using GIT for the first time , then the user needs to set up the email and username using config commands. Let's proceed further

user can use any terminal/Command line prompt.

The above command is used to set the name and email address that is associated with version history

Example:

How to check whether the email and username have been set up or not? So to check the use the below commands:

Now lets move ahead and learn more about GIT commands.

2.Create Repositories

git init

This command is used to creates a new git repository locally in the current work directory or the respective directory. And this practise you should do first while starting a project.

$ git init

After using this command a .git folder is created. Hence, you turns an existing directory into a new git repository by using the “git init” command.

git remote add origin [URL]

After using the git init command, this command specifies remote repository for your local repository. The url points to a repository on GITHUB.

$ git remote add origin [URL]

Example :

git remote add origin "github.com/user/git-demo.git"

basically its link your local repository to remote repository.

git clone [URL]

This command is used for creating a exact copy of your remote repository. Here the benefits of this command is that you don't have to use git init to initialise or git remote add origin [url] to link any remote repository.

$ git clone[URL]

Example:

git clone github.com/user/git-demo.git

3.Saving Changes

git add [URL]

This git command is used to add the modifications/untracked files to the staging area.

If you want to add a single file to the staging area then you can directly specify the name directly after "git add".

$ git add <file name>

If you want to add all the untracked files to the staging area at one go then you can add a period symbol ( . ) or -A directly after "git add".

$ git add .

or

$ git add -A

or

$ git add -u

git commit -m "descriptive messages"

This command is used to commit the staged files with a descriptive message. Message provide the full informations regarding the modifications.

$ git commit -m " changes are modified"

3.Checking status and modifications

git status

this command is used to show the status of untracked, modified and staged files.The tracked files are shown with green files whereas untracked files are shown in red color.

$ git status

git diff

this command is used to compare all the changes that have been made.

$ git diff [first branch]......[second branch]

it shows all the content diffrences between two branches.

4.Ignoring files

.gitignore

This command is used to ignore files (not required) from being tracked with GIT.

$ cat .gitignore

5.Removing files

git rm

this command is used to removes the files from the working directory and the index.

$ git rm <file name>

6. Viewing Commits(make changes)

git log

this command is used to show all the commits done by the people collaborating on your projects. After using git log it will fetch details like developer's name, developer's email, date, time, hash code of that particular commit and subsquently commit message which is provided.

$ git log

git show

this command will fetch the metadata and content changes of the specified commit.

$ git show <commit ID>

7. Tags

git tag

this command is used to capture the point in Git history that specifies the version release. Its of two types one is annotated and other is light weight.

$ git tag

Example

$ git tag v0.1.0 ------->lightweight(created without -a, -s or -m)

$ git tag -a V0.1.4 ------->annotated

🎯How to create a remote repository???

  1. Login into your GitHub Account and on the top-right corner, click on the ' + ' sign drop-down menu and select "New repository".

  2. Write a name for your repository in the “Repository name” field.

  3. According to the preference select Private and Public accordingly. Public repositories are visible to anyone and can be cloned or forked by anyone, while private repositories are only accessible to the owner and other people specifically invited by the owner.

  4. Select "Add a README file" .

  5. Congratulations on successfully creating a repository on GitHub!🎈🎈🎈

Hence we came to end of this article. Hope you learn the basics operations of GIT commands. The aimed of this article is to teach how can we use GIT. So stay tuned to learn more about GIT & GITHUB😎😎😎.