Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

Using Version Control Systems

Version control systems supported by Qt Creator are:

Version Control SystemAddressNotes
Bazaarhttp://bazaar.canonical.com/Qt Creator 2.2 and later
CVShttp://www.cvshome.org
Githttp://git-scm.com/
Mercurialhttp://mercurial.selenic.com/Qt Creator 2.0 and later
Perforcehttp://www.perforce.comServer version 2006.1 and later
Subversionhttp://subversion.apache.org/

Setting Up Version Control Systems

Qt Creator uses the version control system's command line clients to access your repositories. To allow access, make sure that the command line clients can be located using the PATH environment variable or specify the path to the command line client executables in Tools > Options... > Version Control.

After you set up the version control system, use the command line to check that everything works (for example, use the status command). If no issues arise, you should be ready to use the system also from Qt Creator.

Using msysGit on Windows

If you configure Git for use with git bash, only, and use SSH authorization, Git looks for the SSH keys in the directory where the HOME environment points to. The variable is always set by git bash.

However, the variable is typically not set in a Windows command prompt. When you run Git from a Windows command prompt, it looks for the SSH keys in its installation directory, and therefore, the authorization fails.

You can set the HOME environment variable from Qt Creator. Select Tools > Options... > Version Control > Git. Select the Environment Variables and the Set "HOME" environment variable check boxes. HOME is set to %HOMEDRIVE%%HOMEPATH% when the Git executable is run and authorization works as it would with git bash.

Setting Up Common Options

Select Tools > Options... > Version Control > Common to specify settings for submit messages:

  • Submit message check script is a script or program that can be used to perform checks on the submit message before submitting. The submit message is passed in as the script's first parameter. If there is an error, the script should output a message on standard error and return a non-zero exit code.
  • User/alias configuration file takes a file in mailmap format that lists user names and aliases. For example:
     Jon Doe <Jon.Doe@company.com>
     Hans Mustermann <Hans.Mustermann@company.com> hm <info@company.com>

    Note: The second line above specifies the alias hm and the corresponding email address for Hans Mustermann. If the user/alias configuration file is present, the submit editor displays a context menu with Insert name... that pops up a dialog letting the user select a name.

  • User fields configuration file is a simple text file consisting of lines specifying submit message fields that take user names, for example:
     Reviewed-by:
     Signed-off-by:

    The fields above appear below the submit message. They provide completion for the aliases/public user names specified in the User/alias configuration file as well as a button that opens the aforementioned user name dialog.

  • SSH prompt command specifies an ssh-askpass command that you can use (on Linux) to prompt the user for a password when using SSH. For example, ssh-askpass or x11-ssh-askpass, depending on the ssh-askpass implementation that you use.

Creating VCS Repositories for New Projects

Qt Creator allows you to create repositories for version control systems that support local repository creation, such as Git, Mercurial, or Bazaar. When creating a new project by selecting File > New File or Project..., you can choose a version control system in the final wizard page.

You can also select Tools and then select Create Repository... in the submenu for the version control system.

To import a project that is under version control, choose File > New File or Project... > Project from Version Control and select the version control system that you use. Follow the instructions of the wizard to import the project.

Using Version Control Systems

The Tools menu contains a submenu for each supported version control system.

The Version Control output pane displays the commands that are executed, a timestamp, and the relevant output. Select Window > Output Panes > Version Control to open the pane.

Adding Files

When you create a new file or a new project, the wizard displays a page asking whether the files should be added to a version control system. This happens when the parent directory or the project is already under version control and the system supports the concept of adding files, for example, Perforce and Subversion. Alternatively, you can add files later by using the version control tool menus.

With Git, there is no concept of adding files. Instead, all modified files must be staged for a commit.

Viewing Diff Output

All version control systems provide menu options to diff the current file or project: to compare it with the latest version stored in the repository and to display the differences. In Qt Creator, a diff is displayed in a read-only editor. If the file is accessible, you can double-click on a selected diff chunk and Qt Creator opens an editor displaying the file, scrolled to the line in question.

Viewing Versioning History and Change Details

Display the versioning history of a file by selecting Log or Filelog. Typically, the log output contains the date, the commit message, and a change or revision identifier. Click on the identifier to display a description of the change including the diff. Right-clicking on an identifier brings up a context menu that lets you show annotation views of previous versions (see Annotating Files).

Annotating Files

Annotation views are obtained by selecting Annotate or Blame. Selecting Annotate or Blame displays the lines of the file prepended by the change identifier they originate from. Clicking on the change identifier shows a detailed description of the change.

To show the annotation of a previous version, right-click on the version identifier at the beginning of a line and choose one of the revisions shown at the bottom of the context menu. This allows you to navigate through the history of the file and obtain previous versions of it. It also works for Git and Mercurial using SHA's.

The same context menu is available when right-clicking on a version identifier in the file log view of a single file.

Committing Changes

Once you have finished making changes, submit them to the version control system by choosing Commit or Submit. Qt Creator displays a commit page containing a text editor where you can enter your commit message and a checkable list of modified files to be included.

When you have finished filling out the commit page information, click on Commit to start committing.

The Diff Selected Files button brings up a diff view of the files selected in the file list. Since the commit page is just another editor, you can go back to it by closing the diff view. You can also check a diff view from the editor combo box showing the Opened files.

Reverting Changes

All supported version control system support reverting your project to known states. This functionality is generally called reverting.

The changes discarded depend on the version control system.

A version control system can replace the Revert menu option with other options.

Reverting Changes Using Git

The Git version control system has an index that is used to stage changes. The index is commited on the next commit. Git allows you to revert back to the state of the last commit as well as to the state staged in the index.

  • Undo Unstaged Changes reverts all changes and resets the working directory to the state of the index.
  • Undo Uncommitted Changes reverts all changes, discarding the index. This returns your working copy to the state it was in right after the last commit.

Viewing Status

You can select Status... to view the status of the project or repository.

Updating the Working Tree

You can select Update to update your working tree with the latest changes from the branch. Some version control systems allow you to choose between updating the current project and updating all projects.

With Git, you stash your changes and then pull the changes from the repository.

Deleting Files

You can select Delete to delete obsolete files from the repository.

With Git, you delete the files from the working tree and then stage the deleted files for a commit.

Using Additional Bazaar Functions

Bazaar is a free version control system sponsored by Canonical.

The Bazaar submenu contains the following additional items:

Menu ItemDescription
Pull...Turn the branch into a mirror of another branch.
Push...Update a mirror of the branch.

Using Additional CVS Functions

CVS is an open source version control system.

The CVS submenu contains the following additional items:

Menu ItemDescription
EditOpen a file for editing.
Push...Push changes to the remote repository.
UneditDiscard the changes that you made in a file.

Using Additional Git Functions

Git is a fast decentralized version control system. Git is available for Windows, Linux and Mac.

The Git submenu contains the following additional items:

Menu ItemDescription
Patch > Apply from Editor/Apply from File...Patches are rewriting instructions that can be applied to a set of files. You can either apply a patch file that is open in Qt Creator or select the patch file to apply from the file system.
PullPull changes from the remote repository. If there are locally modified files, you are prompted to stash those changes. Select Tools > Options... > Version Control > Git and select the Pull with rebase check box to perform a rebase operation while pulling.
Clean.../Clean Project...All files that are not under version control (with the exception of patches and project files) are displayed in the Clean Repository dialog. Select the files to delete and click Delete. This allows you to clean a build completely.
Launch gitkStart the commit viewer for Git, gitk.
Branches...Manage local and remote branches.
Remotes...Manage remote repositories available in Git.
Stage File for CommitMark new or modified files for committing to the repository. To undo this function, select Unstage File from Commit.
Show Commit...Select a commit to view. Enter the SHA of the commit in the Change field.
StashStore local changes temporarily.
Amend Last Commit...Revert the last commit.

Working with Branches

To work with Git branches, select Branches.... The checked out branch is shown in bold and underlined in the list of branches. Double-click branch names to edit them.

"Branches dialog"

The following operations are supported:

Menu ItemDescription
Add...Create new tracking and non-tracking branches.
CheckoutCheck out the selected branch and make it current.
RemoveRemove a local branch. You cannot delete remote branches.
DiffShow the differences between the selected and the current branch.
LogShow the changes in a branch.
RefreshRefresh the list of branches.

Working with Remote Repositories

To manage remote repositories available in Git, select Remotes.... Double-click the names and URLs of the remote repositories to edit them.

The following operations are supported:

Menu ItemDescription
Add...Add a new remote repository.
FetchFetch all the branches and change information from a remote repository.
RemoveRemove a remote repository.
RefreshRefresh the list of remote repositories.

Using Stashes

With Git, you can put your current set of changes onto a virtual shelf called a stash. Stashes are useful, for example, to put aside a set of changes to work on higher priority tasks or to pull in new chages from another repository.

Qt Creator exposes this functionality in the Tools > Git > Stash menu.

Menu ItemDescription
Stashes...Display a dialog that shows all known stashes with options to restore, display or delete them.
StashStash all local changes. The working copy is then reset to the state it had right after the last commit.
Stash Snapshot...Save a snapshot of your current work under a name for later reference. The working copy is unchanged.

For example, if you want to try something and find out later that it does not work, you can discard it and return to the state of the snapshot.

Stash PopRemove a single stashed state from the stash list and apply it on top of the current working tree state.

Using Additional Mercurial Functionality

Mercurial is a free, distributed source control management tool.

The Mercurial submenu contains the following additional items:

Menu ItemDescription
ImportApply changes from a patch file.
IncomingMonitor the status of a remote repository by listing the changes that will be pulled.
OutgoingMonitor the status of a remote repository by listing the changes that will be pushed.
PullPull changes from the remote repository.
PushPush changes to the remote repository.

Using Additional Perforce Functions

Perforce is a fast software configuration management system developed by Perforce Software.

When you start Qt Creator, it looks for the executable specified in the P4 command field in Tools > Options... > Version Control > Perforce. If the file is not found, the following error message is displayed in the Version Control output pane: Perforce: Unable to determine the repository: "p4.exe" terminated with exit code 1. If you use Perforce, check that the path to the executable is specified correctly in the P4 command field.

If you do not use Perforce, you can disable the Perforce plugin to get rid of the error message. Choose Help > About Plugins and deselect the Load check box for the Perforce plugin in the Version Control group.

The Perforce submenu contains the following additional items:

Menu ItemDescription
Describe...View information about changelists and the files in them.
Edit FileOpen a file for editing.
OpenedList files that are open for editing.
Pending Changes...Group files for commit.

Using Additional Subversion Functions

Subversion is an open source version control system.

The Subversion submenu contains the following additional items:

Menu ItemDescription
Describe...Display commit log messages for a revision.
X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.

[0]; s.parentNode.insertBefore(ga, s); })();
Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. Microsoft ouvre aux autres compilateurs C++ AMP, la spécification pour la conception d'applications parallèles C++ utilisant le GPU 22
  2. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 27
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. RIM : « 13 % des développeurs ont gagné plus de 100 000 $ sur l'AppWord », Qt et open-source au menu du BlackBerry DevCon Europe 0
  5. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
Page suivante

Le blog Digia au hasard

Logo

Déploiement d'applications Qt Commercial sur les tablettes Windows 8

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtcreator-2.3
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web