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.
-
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.
- Commit any changes to your local Git repository (Tools menu > Git > Local Repository > Commit...)
-
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.
-
In Qt, go to the Tools menu and choose Git > Remote Repository > Push
-
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.
-
Go to the Tools menu and choose Git > Git Tools > Git Gui:
-
The Git Gui tool appears. Go to the Repository menu and choose Git Bash.
-
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.
-
At the next prompt, enter the following:
git push <name>
where <name> is the name of your project's remote repository. -
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:
-
At the next prompt, enter the following:
git push --set-upstream <name> master
where <name> is the name of your project's remote repository. -
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.
-
Close the Git Bash window. Close the Git Gui window.