In this article we will cover basic concepts of Git and GitHub in Android. Git is a most widely used version control system in the software development. It is used to manage projects between the team with efficiency and high speed. Git allows us to monitor and work together with our team members at the same workspace. This article will help you to understand the version control system Git with the command line and with GitHub .
Advantages of Git
Git is an open-source version control system which is released with the General Public License.
Git provides scalable features, which means when the number of team member increases, there is not effect to work with git it can easily handle such situations.
Git provides features of distribution means that when you are about switching the project to another machine, you can simply create a “clone” of the entire repository. Also, instead of having one central repository we can create our own repository which the entire commit history of the project. We do not need remote repository to connect. Our changes is stored on our local repository. If need, we can push these changes to a central remote repository.
Git is very secure. It uses SHA1 (Secure Hash Function) strategy to name and identify objects inside its repository. In git files and commits are checked and retrieved by its checksum when we are going to checkout..
Git is very time saving as it can complete all the tasks in a while. Some git operations are performed on the local repository, so that it give us a huge speed.
Branching and Merging
Branching and merging are the one of the greatest features of Git . We can create multiple branches without affecting other branch.
What is GitHub?
GitHub is a code hosting platform which is used to host Git repository.GitHub keep track of the changes made by the developers as it host the source code of your project. It provide distributed version control and source code management (SCM) both the functionality of Git.
Some of its significant features are as follows.
- Collaboration with team.
- Integrated issue and bug tracking easily.
- Graphical representation of branches are very helpful.
- Git repositories hosting.
- Project management system.
- Team management system.
- Code hosting plateform.
- Track and assign tasks easily.
- Conversations system.
Git have various type of commands these are given below
A branch can be consider as a is a version of the repository that is the part of master branch. There can be n number of branch in single project. Git allow us to perform many operations on branch like pull, rename, push, delete, merge etc.
In Git, the checkout command is used for switching between different branch of the same project repository.
Cherry-picking in Git is used to apply some commit from one branch into another branch. Whenever you made a mistake and committed a changes which you have made into the other branch in which you don’t want to commit or in wrong branch, but you do not want to merge the whole branch. So You can revert the commit easily and cherry-pick it on another branch.
In git Clone is a Git command-line utility tool which is used to make a copy of the project repository. If You want to create a local copy of your project repository from GitHub, this tool will help you to creating a local copy of that repository into your local directory from the repository URL.
Fetch command is used to fetch branches and tags from project repositories.
HEAD represent the last commit in the current working branch. When you change or switch branches with git checkout, the HEAD revision will change, and point the new branch.
The Index in Git is known as a staging area between the working directory and repository. Git is used to build up a set of changes that you want to commit together.
Master is a by default branch which is created when clone project from remote server. The cloned repository contains only a single local branch. Which is known as “master” branch.
Merging is a process to merge code from one branch to another branch.
In Git, “origin” is a refer to the remote repository from which a project was initially cloned.
The Pull command is used to retrieve data from GitHub. It fetches and merges the remote server changes into your working directory.
The push command is use to upload local repository data to a remote repository. Pushing can be consider transfer data from your local repository to a remote repository.
In Git Rebase is used for the process of moving or combining the commit sequence to a new base commit.
In Git, the remote is referred to the remote repository. It is a shareable repository that all members of team member can use to exchange their changes. Any remote repository is stored on a code hosting platform like an GitHub, Subversion and internal server.
In Git, Repository can be consider as a space or folder and directory where it contains collection of the file as well as the history of changes made to those files.
While working on git some time you need to switch the branches, but you are working on any project module which is incomplete and you don’t want to make a commit of half-done work. SO git stashing allows you to switch branch without committing the current branch.
Tags help in making a point as a specific point in Git repository history. Using of git help in to mark a commit stage as important. We can also tag a commit for future reference. There are two types of tags.
Upstream And Downstream
The upstream and downstream is a part of the repository. Mainly, upstream is where you can clone the repository from github and downstream can be if any project which integrates your branch work with other branch works.
In Git revert is used for revert some commit. It is command like undo
In Git reset stands for revert or undoing changes. It is used to reset the changes. It has three core forms which are as follows.
In Git, the command ignore used for specify intentionally untracked files which Git should ignore but it doesn’t affect the Files which already tracked by Git.
Git diff can be consider as a command-line utility. It’s a multipurpose Git command. When we are executing it, it will run a diff function on Git data sources and those can be files, branches, commits, and more. It is used for show changes between commit, commits and working tree, etc.
In Git, squash is used for squash previous commits into one. Git squash is very useful to group-specific changes before forwarding them into others.
In Git, rm stands for remove. It is used for remove individual files or a collection of files from repository.