Git | An introduction to get started

Author - Tanuj
10.10.2017
|
0 Comments
|

Git is a distributed version control system. It is a system that records changes in a file or set of files over time so that user can recall previous versions later. As a result of which a user can revert files or project back to previous version, can compare changes, can see who last modified something that might be causing a problem.

Git directory is where Git stores the code of a project and it is copied when user clone a repository to his/her machine. Working tree is a single version of the project. Staging area is a file which contains information about the files that will go in next commit.

Eclipse comes with a plugin called Egit which provides a complete interface to Git operations.
You can clone a git repository by going to Window>Perspective>Open Perspective>Other>Git
1

2

3

By giving the path of a repository you can clone that repository on your local system and modify it without affecting the original.

4

Create a patch – Patch is a file which represents the differences in one or more files. Mainly we use patch when we want to make some changes but we do not have write permission on a git repository in that case we make changes on our branch and creates a patch file that will contain all information related to new changes and send it to someone who had permissions. By this our new changes will also get added to the git repository. It is very simple to create a patch and apply for it see below steps.

1. Go to Team > Create Patch
5

2. In this file you can add all new changes and then apply it to Git repository by going to
Team > Apply Patch
6

3. Stashes- When you made changes to one or more files but it is not completed yet so you can’t commit it that time and you want to work on something else without loosing those new changes then Stashing takes those modified files and saves it on a stack of unfinished changes that you can apply at any time when your work is completed. See an example:

>I have added a demoFunction to the existing file.
7

>Added a commit message that will display when you apply stashed changes.
8

>As you can see in below image your changes are saved by stashing . These all changes are on your local branch and you can apply it any time to repository by selecting Apply Stashed changes. If you don’t want to save these changes then you can delete it by using Delete Stashed Commit.
9

4. Pull – It is used to update your branch i.e to get all changes done by others. Every time you commit your changes you first need to pull or get all changes done by others. Otherwise your request for commit will be rejected if your branch is not updated.

5. Commit – Whenever you made changes to file(s) and you want it to share with other team members then you need to commit those changes so that next time when other team members will pull they will get all changes done by you.

6. – It is the process in which we add all modified files that will be the part of our next commit in staging area.
10

7. Add to Index – Index is the file in which git stores all the files that have been staged and it is also known as staging area. So we can say that it is also same as staging because it just put the modified files in staging area.

8. Revert Changes- Suppose I made some changes and committed it. After some time I realized that I don’t want those changes anymore. Then I can also revert those changes by going to Team > Show History Or Show Annotation. And then right click on that file where you will see an option Revert Changes.
See an example below:

>>I have added a function named demoFunction() in existing file and then committed it..
11

>>By going to Team > Show history below screen will appear which will show the new changes that I have added.
12
13

>>Then Select Revert Commit. After reverting changes the added function function will be removed from the file as you can see below.
14

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

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