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.
For Windows :Use the following site to install github on your machine. Link is given by :
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
Configure local repositories with user information. Set user name and email address.
$ git config --global user.name "User Name" $ git config --global user.email email@example.com
Getting Git Repository
To add git in an existing directory
$ cd /home/user/my_files/project_one
$ cd /Users/user/my_files/project_one
$ cd C:/Users/user/my_files/project_one
$ git init
Cloning an Existing Repository
This is for contributing to a project or repository. Run :
For example, if we have to clone the Git file called
HelloWorld,then following can be done :
$ git clone https://github.com/jagritiS/HelloWorld
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
The simplest way to commit is to type
$ git commit
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 your local repository with the remote repository
$ git pushUploads all local branch commits to GitHub
$ git mergeCombines remote tracking branch into current local branch
$ git fetchDownloads all history from the remote tracking branches
$ git pullUpdates 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
Subscribe to our Youtube ChannelSubscribe