How to Use git Version Control in QT Creator in Windows XP

Source: Internet
Author: User
Tags touch command hosting how to use git using git git commands
How to Use git Version Control in QT Creator in Windows XP

Qt creator is an IDE development tool specially designed for the QT application development platform. It integrates many functions, including windows, Linux, and Mac versions. For developers who frequently use QT, we will not discuss it much. The following describes how to use Version Control in QT creator. In QT creator, you can select git or subversion for version control. I chose git. Why? You can refer to the two articles <Git-basics> and <Git-tips>. If you are familiar with GIT for a long time, go.

Note the following prerequisites:

1. We are in windows, but git was originally born in Linux (Great God). Fortunately, there are already enthusiastic developers who have created installation packages for Windows. Currently, there are several similar open-source projects, all of them are migrated from git to Windows. Here is a good one, and it is ".

2. If you are using git on your local machine or in the company's internal environment, please visit the Internet for details about the specific environment. Here, we use the existing Git hosting service, and then develop it locally and synchronize it to the hosting server. There are a lot of hosting services, such as SourceForge and Google code, but it seems that all of them are SVN. GitHub is a good solution for git, and there is a free space of m after registration, if you pay for it, you can get more space and services. Hurry up.

If you have installed msysgit and activated the GitHub hosting service, continue.

3. Set the SSH public key. Note: it is very important to correctly configure this step. We must have at least one SSH public key to connect to and operate projects on GitHub or other repo points. Open git Bash. here we need to configure the SSH Public Key between the local and github.com,

First, enter ssh-keygen-c "your email address"-t rsa. Make sure that the Enter key is used four times in a row, regardless of whether you need to enter anything else. This command generates an asymmetric public/private key, which is stored in

XP/2003 users: C:/Documents and Settings/login name/. SSH

Vista User: C:/users/login name/. SSH

In the. Ssh folder, place the key in the id_rsa file and ignore it. Put the SSH Public Key in id_rsa.pub. Open it in a text editor and copy all the characters in it. Assume that you have registered a GitHub user. On the Account Management page, you have a large "ssh public keys" column. Click "add another public key ", title can be blank (the default value is email) or arbitrary. paste the copied character in the key text field and click Add key!

4. After SSH is successfully created, create a new project on the GitHub website and create a new project/create a new repository, for example, create a god project, remember the your clone URL you saw: git@github.com: ynshisss/God. git, ynshisss is my user name, "/" is followed by my project name "God ". Okay: Back to the DOS window, we need to set the global user name and email so that git can know who you are and enter:

Git config -- global user. Email "your email address"

Git config -- global user. Name "your name"

Not strictly speaking, this step can be ignored. It does not affect your subsequent operations on the project, but only allows git to record who is performing the operations. I believe that the effect is visible when the same SSH public key is used for the same project during the development of multiple teams.

5. Create a local git repository to store your project, create a folder named "God" under D:/, and then CD it to the D:/God/directory,

Type> git init to initialize the current git repository directory.

Type> touch readme: Use the touch command to create a file named readme.

Type> git add readme to add the file readme to git Version Control

Type> git commit-m'add file readme 'to submit the new version to the GIT repository.

Type> git remote add origin git@github.com: ynshisss/God. git creates a local branch named origin for the remote server, and later you need to submit local updates to the remote server, you can replace "git@github.com: ynshisss/God." With the origin alias. git"

Type> git pull origin master to update the content of the master branch of the remote server to the local branch (by default, you have not created a new branch, so there is only one master branch remotely and locally, the names are all master nodes. For details about how to use the branches, refer to the official git manual)

Type> git push origin master submit all the modifications of the local master branch to the master branch on the remote git Server

After completing the above operations, you can visit your project on GitHub to see if there is a file readme in God.

6. Open QT creator and create a QT project under the newly created local git repository Directory D:/God/. Note that your project must be under the GIT repository directory, otherwise, QT creator cannot enable version control. Set tools> options... --> git, enable environment changes, and ensure that git.exe can be found.

Select window-> output panes --> git, open the GIT prompt output window, and edit your project as needed, such as modifying main. cpp, and then

Select Tools-> git --> commit command to submit the modification. If the message prompts "Git status -ucommand error or no effect, the pathvariable cannot be found in git.exe, and the environment variable is reset. The commit command submits the update to the local repository, in this case, a submission window is opened, asking you to enter the submission information. All information must be entered.

After the submission is complete, select Tools-> git --> push command to synchronize the local version to the server. If the message prompts "time out", what is the problem?

If I use the GIT bash environment, CD to D:/God/, type> git push. If the push fails, check the prompt, it probably refers to the branch to which you want to synchronize data. If it is for the current branch, you can set config ..., okay, Let's type> git push origin master. It succeeded. It turned out that the push command in QT creator could not find the remote server address and synchronization branch. What should I do, I just prompted that you can use config to set global variables, but it is better to modify D:/God /. open the GIT/config file and see what:

[Core]
Repositoryformatversion = 0
Filemode = false
Bare = false
Logallrefupdates = true
Symlinks = false
Ignorecase = true
[Remote "Origin"]
Url = git@github.com: ynshisss/God. Git
Fetch = + refs/heads/*: refs/remotes/ORIGIN /*

Add the following to the config file:

[Branch "master"]
Remote = Origin
Merge = refs/heads/Master

Now when you use the> git push command, the master branch is synchronized, and its remote is the origin, that is, git@github.com: ynshisss/God. Git.

Use QT creator again for synchronization. If the update is remote to local, use push. For more git commands, see Official manual.

Related Article

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.