Preface
It is speechless that many people around the research program design will not use the version control system, so I will write this tutorial. The main audience of this tutorial is Windows users who have never used version control systems or git. If this response is good, I will add the GIT command on the CLI on Linux next time.
First, why should we use a version control system? The version control system has the following important functions:
Record all original code change processes and back up to view original code modification history or restore old versions to work with people to efficiently synchronize the modified content using branch) to maintain multiple program versions at the same time
These functions bring many benefits, including:
Don't worry about changing things will mess up a program, you don't need to manually back up each version, you don't need to use comment in the original code) to keep unused syntaxes. When you share the original code with people in the team, you do not need to zip the code, and then use e-mail to E-mail (note 1)
Because of these advantages, professional program developers do not need a version control system. Therefore, it is difficult to take some time to learn about the version control system.
* Note 1: Yes, I am speechless about this. After this tutorial is posted, I will consider rejecting the original zip code.
Git Introduction
Git was developed by Linus Torvalds, a famous Linux kernel developer, to facilitate Linux maintenance. Git has the following features:
The distributed version control system (distributed version control system) is very fast and can be used to reduce the size of small files by using gzip when transferring files, it can even interconnect with a version control system of a non-Git system
These features are part of the middle-level git teaching content.
GitHub Introduction
GitHub is a platform that provides online git space, allowing multiple developers to easily develop software together. The provided solutions include free and paid accounts. The difference is whether you can use private space. Although free accounts can only use public spaces and all original codes must be published, this is not a problem for many projects. There are no other restrictions on free accounts.
Advantages of using GitHub include:
With online original code and modification history browsing, developers can easily share original codes. Someone creates a branch (fork) more and more well-known enterprises that can track all branches require the applicant to provide a GitHub account to observe their participation in the open source software community, there are also program writing styles and skills (note 2)
Therefore, GitHub is a very good platform to participate in open-source software development or simply back up/centrally organize your original code.
* Note 2: however, if your GitHub account has a space hole or scrawled code, do not give it to your employer to avoid points deduction. Therefore, I have rejected some job seekers who provide GitHub accounts but have no content.
Tortoisegit
Although it is necessary to use git commands to completely experience the powerful features of git, tortoisegit may be more friendly to those unfamiliar with the command interface, and can have a good balance between functionality and ease of use.
Tortoisegit can be downloaded here: http://code.google.com/p/tortoisegit/downloads/list. Choose to download 64-bit or 32-bit versions based on the system type. Download the 64-bit or 32-bit version, install it, and restart the system.
After restarting, install msysgit at http://code.google.com/p/msysgit/downloads/list. Download Full installer for official git 1.7.6 or the latest version. After this is installed, tortoisegit can be used normally.
Create a git Project (init) and store modifications (COMMIT)
First, right-click an existing project folder or a new folder and select git create repository here .... This will create a new git database,
To store original code data. When the GIT init dialog box appears, do not check make it bare and click OK. After that, you can see a hidden. Git folder if you have enabled the folder to display hidden files.
After the GIT database is created, set the author information. Right-click the folder and choose tortoisegit> Settings. Go to the git-> config page, enter your name in name, and enter your email. Click OK.
After saving the original code, right-click the folder and select git commit-> "master ". Master refers to the current branch. If there is a sequel to this tutorial, I will explain it again.
When the commit window appears, enter the comment to store the change in the message. Good developers generally describe the newly added or changed content of this change here. Enter a message and check the file to be saved. To store changes in all files, check select/deselect all. After that, click OK. After the storage is complete, click Close to close the window.
After the account is created, click New repository to create a source code library. Enter the project name and press create repository.
After the project is established, copy the link to the source library, such as the git@github.com: vvasabi-test/test-project.git. Return to the project folder, right-click and choose tortoisegit-> Settings.
In this window, select Git-> remote, enter origin in remote, paste the copied link in the URL, and click Add new/save. After that, press OK.
You only need to perform these steps once for each project.
Upload modification content (push)
Now upload the modified content to GitHub. First, create an authentication key. Choose Start> All Programs> tortoisegit> puttygen. Click Generate, wait for the program to run, and then click Save private key to save the key to any location. If you need to ensure that the key will not be stolen, you can enter the key passphrase before storage to use the password to protect the key (the same password must be entered in confirm passphrase ). If you do not enter the password, you can click "yes" when puttygen warning appears.
After the key is saved, go back to the Start menu and start all programs-> tortoisegit-> pageant. In this case, the Status column will run out of a new icon. Right-click the icon and select Add key, and then select the key you just saved.
Return to the putty key generator window and select and copy the public key. Open the GitHub page and click Add your public key. Click Add another public key, enter a random name in the title column, and paste the key in the key column. After that, click Add key.
Although it is difficult to set the key, the good news is that a computer only needs to be set once.
Return to the project folder, right-click, and choose tortoisegit-> push .... Tick push all branches, click OK, And the putty security alert time point is yes (this will only appear once ). If no error warning is reported, the project is successfully uploaded to GitHub.
Daily Work Flow
Setting GitHub at the beginning is very troublesome. People who are too lazy to set these steps can only use git instead of GitHub. However, most of these settings only need to be operated once, so it is best to patiently complete these steps.
When you modify a program code, you need to store the changes (COMMIT) after the modification. Right-click the project folder and click git commit-> "master ".... Enter the modified message, select the file to be saved, and press OK.
After that, click tortoisegit-> push... To upload the changes to GitHub. Tick push all branches and click OK. If an error occurs, make sure that pageant is enabled. If not, follow the steps above to enable pageant and add the previously stored key.