Summarising Github

Summarising Github

Git is an open-source distributed version control system that facilitates GitHub activities on the laptop and the desktop. Here is a basic summary of git command-line instructions for reference.

Installing GitHub

For Windows :Use the following site to install github on your machine. Link is given by :

https://desktop.github.com/

For Linux : Open terminal and run the following command : (for debian based)

$ sudo apt install git-all 

For Mac : On Mavericks (10.9) or above you can do this simply by trying to run git from the Terminal the very first time.

$ git --version

If it is not installed already, it will prompt for installing.

For more updated version, install it via a binary installer. A macOS Git installer is maintained and available for download at the Git website, at 

https://git-scm.com/download/mac.

Git Configuration

Configure local repositories with user information. Set user name and email address.

$ git config --global user.name "User Name"
$ git config --global user.email example@abc.com

Getting Git Repository

To add git in an existing directory

for Linux:

$ cd /home/user/my_files/project_one

for macOS:

$ cd /Users/user/my_files/project_one

for Windows:

$ cd C:/Users/user/my_files/project_one

and type:

$ git init

Cloning an Existing Repository

This is for contributing to a project or repository. Run :

 git clone.

For example, if we have to clone the Git file called HelloWorld,then following can be done :

$ git clone https://github.com/jagritiS/HelloWorld

Ignoring Files

Often, you’ll have a class of files that you don’t want Git to automatically add or even show you as being untracked. These are generally automatically generated files such as log files or files produced by build system. In such cases, you a file can be created with listing patterns to match them named .gitignore.

Committing Changes

The simplest way to commit is to type git commit:

$ git commit

Branches

Branches are an important part of working with Git. Any commits will be made on the branch you’re currently “checked out” to. Use git status to see which branch that is.

$ git branch [branch-name]
Creates a new branch
$ git checkout [branch-name] 
Switches to the specified branch and updates the working directory
$ git merge [branch]
Combines the specified branch’s history into the current branch. This is usually done in pull requests, but is an important Git operation.

Synchronize changes

Synchronize your local repository with the remote repository
on GitHub.com

 $ git push
 Uploads all local branch commits to GitHub
$ git merge
 Combines remote tracking branch into current local branch
 $ git fetch
 Downloads all history from the remote tracking branches
$ git pull
 Updates current local working branch with all new commits from the corresponding remote branch on GitHub. git pull is a combination of git fetch and git merge 
Share this on facebook

Subscribe to our Youtube Channel

Leave a comment

Your email address will not be published. Required fields are marked *