My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Synopsis of Unix, Git and Github.

Vikas Kumar's photo
Vikas Kumar
·Oct 19, 2021·

5 min read

What is Unix?

Ans. To make you understand this better, will explain in points about Unix which are given below:-

  1. So, first of all Unix is a family of operating system like Mac Os ,Android,Linux etc.

  2. The core of Unix is called Kernel. It controls and manages in the system.

unix_architecture.png

In the above picture, shell is the interface between the user and kernel and it accepts and interprets the commands through a command line interface (CLI) also called terminal. some types of terminal are BASH (Bourne Again Shell) and C shell.

Basic Shell Commands

pwd :- It will shows the current path of the directory.

ls :- This will lists all the files,folder and directory as well.

cd :- It takes requires the file name or a directory to change to a specific location.

cd .. :- It will takes you one level back in a particular folder or directory.

man :- It is very useful, i mean you can learn about any command. When you will run
this command it will show you the manual of any command.

### Let's move on to the CRUD {Four Basic Operations }

  1. C in CRUD stands for creating a file or folder. We can create it by using command called touch. And also it takes a file name that we want to create.

  2. R in CRUD stands for reading a file or folder. We can read it by using command called head and tail. Head command will print the first 10 lines by default and the tail command will print the last 10 lines by default. cat is also an command which can takes many files at once and prints all the lines
    from the given files.

  3. U in CRUD stands for updating a file or folder. we can update a file by using a command called echo. nano is an another command to make changes or update a specific file or folder.

  4. D in CRUD stands for deleting a file or folder. rm is the command to delete it.

Basic Shell Command - working with directory/folders

  • mkdir :- This will create a directory.
  • mv :- It stands for move and is used to change the name of file.
  • cp :- This command will help to copy a file. It requires a source and destination file name.
  • rmdir :- This stands for removing any directory.

Introduction to Git and Github:-

git-vs-github.png

Basically Git is a version control system. It is very useful in all types of projects and especially the project which has hundred's and thousands of files. It help us to keep the accountability of each file.

More benefits of using git are given below:-

  1. It makes easy to compare the changes.
  2. Also we can share these copies and work with other people.

Git provides us three stages:-

  • Working Tree.
  • Staging Area.
  • Committed Area.

There are some git commands that we use:-

git init - It helps to track the folders via initializing git

git status - Check the status of a repository.

git log - Check the commit history.

git add - Add file to staging area.

git commit -m "" - Moves file from staging area to committed area.

git restore --staged - Moves file from staging back to working area.

git checkout - Go back to the stage of working tree in a particular commit.

BRANCHING AND MERGING -

Git gives us a tool to use through which we can make branches and work with a team. One of the best thing about creating a software is that it is developed in a non linear fashion, it means that there are many people working on multiple features such as experimentation, bug fixes etc simultaneously on the same project. So this branching helps in making this possible.

To make a branch we use a command called git branch

Q. How can we merge two branches?

Ans. We use two types of merging which are fast forward merge and 3-way merge. In fast forward, there is direct path b/w two branches. And for 3-way merge when there is no direct path b/w the branches that we want to merge into.

Commands :- git checkout - switches to the specific branch. git merge - merge the given branch into master branch. git checkout -b - creates and switches to the branch. git branch -d - deletes a branch.

Q. How do people collaborate via Github?

Ans. Github is service that we used to host git repositories in order to collaborate with other people. To collaborate with a team, we have to first add a url to our local repositories. we can add remote url through a command called git remote add origin .

We can check all the remotes of any repositories by remote a command called git remote -v.

We can upload our changes from our local repositories to the remote repositories by using a command called git push origin master. For each branch that we push to the remote repo, then remote tracking branch will be created and basically the role of this branch is to tell us what the master branch looks like.

Pull Requests:-

Github-WorkFlow-Tips-Crunchify-Tips.png

Pull requests tell others about changes that anyone has pushed to a branch in a repository on GitHub. Once a pull request is opened, we can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch.

git clone :- clones(makes a new copy) of a remote repositories to our local machine.

git fetch origin :- downloads all changes from origin remote repo to local repo.

git pull origin :- download all changes from remote branch to local branch.