Use version control system git on qtcreator (i)

Source: Internet
Author: User
Tags commit openssh server version control system

On the Qtcreator.

Using the version control system git (i)

In an article about git, the authors say the version control system is for lazy people, and it makes lazy people have cleaner file systems and more time to live than those who are good at backing up documents. I agree with that. At the same time in today's fast-paced society, improve teamwork efficiency is the key to the survival of the team. So, this is a strong belief in my choice of version control system.

Git was my first contact with the version control system. Some students say you do not use SVN ah, I retort: Git is the father of Linux Linustorvalds single-handedly built, for Linux systems and open source project management of course good. In fact, I built git on the qtcreator is also a bit of a struggle, and now finally succeeded, happy to write an article to sum up. If there is anything wrong, please don't hesitate to bring it up, I will correct it.

My current development environment: Ubuntu11.10, QtCreator2.41, Qt4.8.

Are you sure the Qtcreator is installed correctly? Please look here.

Now start installing the relevant components: git first. Ctrl+alt+t Open the terminal, enter Sudoapt-get install git, return, install Git.

To make it easy to use git, you must also install GITK, the graphics side of this git. Command: Sudoapt-get install GITK.

Then there is the need for team development openssh. Because we want to communicate with a lot of hosts, we have to make sure that your connection is secure and that OpenSSH can meet our needs. The installation command is: Sudoapt-get installopenssh-client. If you create a code base and make your own machine a server, you will also need to install the OpenSSH server version, command: Sudoapt-get install Openssh-server.

Have installation OpenSSH problem, can move to: here.

After installing Git, we see that Qtcreator has detected the existence of git. There are git options in the version control and Tools menu.

There are a lot of git command-line related articles on the web, and I'm not going to go into it anymore, so I'll explain how git can be used with qtcreator. Note: Qtcreator converts all Chinese in the path to \NNN (n as a number) in the specification, which in git can cause the location to fail (because Git recognizes the Chinese path).

Create a new item, shortcut key CTRL + N. Remember that the path to the project can not have Chinese, must be in plain English form, where I set up a pure C project named "Test".


Click Next and the Version control option appears, choosing Git, as shown below. When we create a project, we have a. user file that holds some user miscellaneous configurations, but different users have different preferences, so this file is not managed by git, and we have to say qtcreator this is very detailed.


Next, then don't let me say it, finish. Create a pure C project, in fact, is HelloWorld. Let's assume that this HelloWorld is the first version and we're going to use this as the initial version, so we should click on "Tool ➡git➡commit ..." as our first submission and also the first version.


After filling in the author and email information, you can write a description. Here is a description of the input box to make some note: First in my qtcreator version of a Chinese on the crash (automatic exit), very annoying, so this time I did not fill in the Chinese information, but use git command (command: Gitcommit, Open the Gnunano Editor) to fill in Chinese. Besides, do you notice? The first line is bold, and the second behavior is empty, because a lot of information services (such as log introduced next) will take the first line as the title, followed by the text. Command

When you have completed and selected the file you want to submit, click Submit, so git stores a version of the information for us.

Would you like to see the version information you submitted? Click "Tools ➡git➡log" to display the submitted version information. The following figure:


Click 2552bae, it will show the version information displayed in English, bad English students are bad ...


Next I'm going to make some changes to this project, and we'll let it show another text: hellogit!, and name this version 1.1. First we modify the source file Main.c, the modified MAIN.C is as follows:

#include <stdio.h>

Intmain (void)

{

printf ("hellogit!\n");

printf ("helloworld!\n");

Return0;

}

Where the blue font is part of what we added. Next we save it, but that doesn't mean submitting to Git, because when you click on "Tool ➡git➡ State", the following output displays this string of text:

#Changes not staged for commit:

# (use "Git add <file> ..." To update what'll becommitted)

# (use "Git checkout-<file> ..." to discard changesin working directory)

#

#modified: MAIN.C

#

#Untracked files:

# (use "Git add <file> ..." to include in what'll becommitted)

#

#test. Pro.user

Nochanges added to commit (use "git add" and/or "gitcommit-a")

Shows that our main.c has been modified but not submitted to Git (Test.pro.user is not managed by Git because, as mentioned above, each user miscellaneous is saved by a. User, and loss of it will not affect the project's settings). So we have to submit (commit) again.


When you have finished, click Submit and the new version 1.1 is complete. How, is not very simple AH.

Check out the Log (tool ➡git➡log) and now have two versions.


Suppose our 1.1 version is poorly written, or the original code is messed up, and we want to revert to the original version 1.0. Quite simply, using GITK can solve the problem. Open GITK, and this interface appears:


Select Ver1.0, right-click, select "Resetnaster Branch Tohere", select Hard in the pop-up dialog box, and click OK to complete the version of the restore. It should be noted that the choice of hard mode means that all changes in the new version are void, so be careful to deal with.


Back to the Qtcreator interface, found that prompted to reload the file, click "All is" on it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.