Qt & Git: Configuring and Pushing to a Remote Git Respository

This tutorial walks you through configuring a remote Git repository for use with an existing Qt project. You can then push your commits to your remote GitHub, BitBucket, etc. account.

  1. Open the Qt project for which you want to set up a remote Git repository.

    NOTE: This assumes you set up a local respository for your project.

  2. Commit any changes to your local Git repository (Tools menu > Git > Local Repository > Commit...)
  3. Go to your GitHub or BitBucket account and create an empty repository for your project.

    TIP: Use the same name for the repository as your Qt project.

  4. In Qt, go to the Tools menu and choose Git > Remote Repository > Push

  5. You'll get error messages in Qt's Version Control window similar to the ones below:

    You need to configure the remote Git repository settings for this project. The commands in the error message will help you did that.

  6. Go to the Tools menu and choose Git > Git Tools > Git Gui:

  7. The Git Gui tool appears. Go to the Repository menu and choose Git Bash.

  8. The Git Bash console window appears. At the prompt, enter the following command:

    git remote add <name> <url>


    where...

    • <name> is the name of your project's remote repository.
    • <url> is the URL (address) of your project's remote repository.

      HINT: copy the .git address from your remote repository; right-click on the Git Bash console window and choose Paste.
  9. At the next prompt, enter the following:

    git push <name>


    where <name> is the name of your project's remote repository.

  10. Another error appears, telling us that the 'master' branch has no upstream branch on the remote repository, along with a command to resolve the issue:

  11. At the next prompt, enter the following:

     git push --set-upstream <name> master 


    where <name> is the name of your project's remote repository.

  12. If you see messages similar to the ones in the screenshot above, your project is now in your remote repository. Go to your GitHub/BitBucket account and verify that's the case.

  13. Close the Git Bash window. Close the Git Gui window.

× Tip:   In the future, you can push this project's commits to your remote Git repository from Qt's main screen by doing Tools menu > Git > Remote Repository > Push