Commit your first change

When working with Git, you typically check and stage you local changes, commit them to the local repository, and then push them to a remote repository (origin).

Before you start, set up Git in Preferences > Version Control > General.

Commit to a new repository

To commit and push your first change to a new repository:

  1. To start tracking changes, go to Tools > Git, and then select Create Repository.
  2. To view local changes, go to Tools > Git > Local Repository and select Diff.

    {Git Diff Repository view}

    Git Diff Repository view

  3. Right-click a changed line and select Stage Chunk to add the chunk to the staging area or Stage Selection to add the selected lines there.
  4. To commit the staged changes to the local repository, go to Tools > Git > Local Repository and select Commit.

    {Git Commit view}

    Git Commit view

  5. Select the files to commit, and then select Commit <n/m> File(s) to commit the changes to the local repository.
  6. To push the committed changes to a remote repository, go to Tools > Git > Remote Repository and select Push.

    If the local branch does not have an upstream branch in the remote repository, Qt Creator prompts you to create it and set it as origin.

Commit to an existing repository

To commit and push your first change to an existing repository:

  1. To pull changes from a remote repository, go to Tools > Git > Remote Repository and select Pull.
  2. Select Stash & Pop to stash all local changes before pulling and to apply your stash on top of the pulled working tree state.
  3. To commit the changes to the local repository, go to Tools > Git > Local Repository and select Commit.
  4. To push the committed changes to a remote repository, go to Tools > Git > Remote Repository and select Push.

See also How To: Use Git and Git.

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.