The introduction

As a programmer, besides writing code, I also deal with the version control of project code. With the help of SVN and Git, we can control the project version well. Because you benefit from it every day, here are some examples to illustrate the power and convenience of a version management system.

The instance

Suppose one day your boss assigns you a task. There is an XXX activity in the company and you need to think of a copy to promote it. The task that the boss decorates cannot careless of course, then you wrote a copy very quickly, the boss put forward a few revises opinion after looking. After the revision, you take it to your boss, who puts forward some suggestions. So on after a few back to the boss feel or the beginning of the document is more appropriate, when your heart is collapse, changed so many times who remember what is the beginning, but you can only be struggling to recall, and make a note of this lesson, the next time changes all the time to leave the first, and then started to write a new copy.

One day, the company has another event, and your boss finds you again. This time, you have learned to be smart. Although you have revised several times, this time you keep the original folder and start to write a new one, and your folder will probably look something like this:

Git is used for project version control in software development. However, as long as files can be added to git version control, such as the example mentioned above, you can use Git to control version.

About the git

Git is just a name. There is no need to resist accepting it as soon as you hear a completely strange word. It is just a synonym of technology like Android and iOS, which will not feel strange after being used for a long time. Git related information can be Google or Baidu. I’m going to use SourceTree for this demonstration, which can be downloaded here.

SourceTree is used

First of all, we will create a folder to store our copy of the first edition, and the file directory is as follows:

Then we use SourceTree to manage our files. SourceTree is a graphical software for git operations that makes it more intuitive to use Git.

When the SourceTree download is complete, the interface opens like this (on Mac) :

Click “Create local repository”, then select “boss files” folder, so that all files in this folder are added to git version control, and then use git to control the history of all files in this folder perfectly.

Double-click the newly added option to enter the interface as shown below:

The red box area is our file. When you complete a release and save it, the action in Git is commit, as follows:

Area 1 is the file we want to commit, the check means commit, area 2 is the comment of the commit, which explains what is committed this time, area 3 is committed, after the commit is complete, click the view switch of area 4 to enter the mode shown in the following image.

At this point, we are done committing a version. If the subsequent boss has revised the opinion, we can rest assured that boldly open the original file began to modify. After the change is complete, we need to add the identified files to the version management. The process is the same as the first COMMIT process, which is not described here. After committing the changes a few times, we should see something like this:

If the boss thinks the first version is better, don’t panic, this time we have the help of Git, double click the record “boss wants copy 1”, you will see the following popup box:

When you click on the file, it magically happens. The contents of the file will look like the first version of the file. This is the power of Git, which allows you to travel through the submitted versions as if you were in a time machine. You double click “boss wants copy 3” again this record, the file under the folder shows the content of your last copy.

Git is a powerful tool that allows you to retrieve files even if they have been deleted by mistake.

The above examples give you a rough idea of how powerful Git version management can be. There are many other features of Git as well. If you are still interested, you can continue to Google Git to learn more about its features and improve your work efficiency.

Reprint please indicate the source, have any questions can contact me, welcome to discuss.


Finally do a promotion, welcome to pay attention to the public account MrPeakTech, I learn a lot from here, recommend to everyone, common progress ~