Basic commands in GitHub

Git is the open source distributed version control system that facilitates GitHub activities on your laptop or desktop. The
commonly used Git command line instructions are:-

Create Repositories
Start a new repository or obtain from an existing URL
$ git init [ project-name ]
Creates a new local repository with the specified name
$ git clone [url ]
Downloads a project and its entire version history

Make Changes
Review edits and craft a commit transaction
$ git status
Lists all new or modified files to be committed
$ git diff
Shows file differences not yet staged
$ git add [file ]
Snapshots the file in preparation for versioning
$ git commit -m “[descriptive message “]
Records file snapshots permanently in version history

Group Changes
Name a series of commits and combine completed efforts
$ git branch
Lists all local branches in the current repository
$ git branch [branch-name ]
Creates a new branch
$ git checkout [branch-name ]
Switches to the specified branch and updates the working directory
$ git branch -d [branch-name ]
Deletes the specified branch

Synchronize Changes
Register a repository bookmark and exchange version history
$ git fetch [bookmark ]
Downloads all history from the repository bookmark
$ git merge [bookmark /[branch]]
Combines bookmarks branch into current local branch
$ git push [alias [branch]]
Uploads all local branch commits to GitHub
$ git pull
Downloads bookmark history and incorporate changes

Some advanced commands

Now let’s talk about some of the advanced commands. So lately I have been working on many of the open source projects. Which gave me a lot of idea about the way the things happen in the open source industry. As much time you spend in this part, more will you learn about the things happening.

From a long time, I was working on a single user project where all the development is done by the single user. So your code remains intact and no damage is done to your commits. But the case is totally different when it comes to the big projects. There are constant commits that are happening in each second. So by the time you are ready to push the code to a repository for merging you are behind the main repository by at least three to four commits.

So the idea is to get the code from the main branch merge the commits into your code and then push the changes back into the main repository. Also in the case big repository you can’t give the excuses like that you are new to the GitHub. If you don’t evolve early, get ready to be ignored by the open-source industry.

So whenever you want to commit a change that you have done to the repository put the changes into the stash by using these commands.

$ git stash 
# read more about git stash by using the following command
$ git stash --help
# The following command will list the saved data in the stash
$ git stash --list

stash is the part where you can store the things in the temporary mode they can be brought back to their earlier position when other changes are committed. It is the time to fetch the data that had been changed the main repository.

But before fetching it is great to make a remote of the forked repository so that we can directly fetch the changes from the terminal else we have to type the link of the forked repository again and again. Obviously, it is not necessary but it will make our work easier.

$ git remote add upstream http://github.com/remote_link_to_the_repository

The command tells us to add a new remote to the local repository by the name of upstream which is linked to the link provided as the next parameter. Now, whenever we want to know about the changes made in the particular branch we can simply type the name of the branch and we will get the code given by it. Then finally we will use the merge command to merge the code into the local repository. See the example code snippets for more information.

$ git fetch upstream/branch_name

$ git merge upstream

Rest of the information will be shared in the follow-ups.

Vim : The best text Editor

Before talking about the training I want to tell about the various things that I am using while writing about them.

  • Ubuntu 15.10 on my system

Day 1

This is the day one at the training institute and Inder sir introduced Vim to us. He told us about the various modes of this text editor.

I installed this on my system by using the command.

sudo apt-get install vim

He told us about the various commands in the Vim. I liked the thinking of not moving your hand off the keyboard so I explored more about this. I used one of the great website of tech world called linux.com for the reference purpose.

So lets start with the things that I have learned about Vim.

Why would you even try to move your time toward learning a full flagged text-editor. Vim is world’s best text editor for a reason whenever you work with Vim you never have to move your hand off the keyboard. You don’t need to go to mouse again and again and waste your time in the purpose. Your total typing speed will increase in the long run. Although their may be dip in the speed when you are trying it for the learning purpose but if you choose to start then this will the best decision that you might have made in a long time.

Modes

Many people in the tech may contradict this but in this post we will be talking about three modes in the vim. These three modes are

  • Command Mode
  • Insert Mode
  • Last-Line Mode

We can check for the version of Vim by launching the command

vim -v

Press :q to quit this mode.

Whenever we open a file by placing a command

vim filename

where filename is the preffered name of your file, this command first checks for the  existence of the file. If the file exist then it opens it and if their is no file by this name then it create it and opens a blank file for us with ~ sign on the beginning of each line. This sign represents the empty line in the document. Now on giving this command the editor opens in the terminal only. The first mode in which the file opens is the command mode this mode is used is used move in the document i.e. you can press j to move the cursor one line down.(we will discuss more about the commands later.

We can switch to the to insert mode by using i key. Press i key to open this mode. You can change anything in the document when you are in this mode.

The other mode is Last-Line mode which used for other purposes like saving the file.

This is the basic overview of Vim. Please refer to other posts in the category

MathJax : Write math on the browser

First of all I would like to link to the presentation which you can check. This presentation will let you more about the MathJax.

http://singh1114.github.io/presentations/mathjax.html/

MathJax is a tool which is used to lay out the math on the browser in a better way. Tex and Latex has been used since a while now to write big mathematical formulas in the form of a pdf. MathJax make use of these two ways to write math on the browser.

MathJax is a JavaScript library which can be used in collaboration with Tex, Latex, MathML and AsciiMath. These three are used to write mathematical formulas at various points.

Prior from MathJax images were used to put a mathematical formulas on the browser which was quite a big deal to lay them out properly on the browser. Also these images were headache for the visually impaired people as screen reader were not able to guess what was written on the image. To solve all these problems MathJax was introduced.

There are two ways to implement Mathjax.

  1. Through CDN (content delivery network)
  2. By downloading the files

Now let us discuss about the CDN implementation. This implementation is discussed properly in the documentation on the MathJax official website. Here is the link for it.

http://docs.mathjax.org/en/latest/start.html

In the head section of your website write these lines of code.

<head>

MathJax.Hub.Config({tex2jax: {inlineMath: [[‘$’,’$’], [‘\\(‘,’\\)’]]}});

https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML
</head>

Now you can use Tex, Latex, MathML or Asciimath code anywhere on the page and that will be implemented as a mathematical formula.

If you wish see an example here is the link.

http://singh1114.github.io/mathjaxprogram.html

Another way of doing it is by cloning the github repository. Clone the github repository and you will find the a folder named test. In there you will find a file named example.html. Run this file and run various examples. Create any files in this folder and add script files as in the examples add any Tex, Latex or MathML content to show them on the browser.