Qt and Git



  • I'm new to both Qt and Git, so this question could easily go on a newbie git form.

    What files should I be tracking in my project? The obvious answer is anything I want backed up; however, do I need all these extra files or just my code?

    For example, when I create a project Qt makes three directories: ProjectDir, ProjectDir-build, and ProjectDir-debug.
    Do I need to track all three of these directories? Or can I just track the main dir that has the .pro file, all my .cpp and .h files?

    This is my first Qt project, and first time using git. Any advice would be nice.



  • Just use git for your your ProjectDir, you don't need to use git in the other directories.
    If you find usefull, here is a cheat sheet of most comun 12 git comands I use.

    @Sets the name of the user for all git instances on the system

    $ git config --global user.name "Firstname Lastname"
    $ git config --global user.email "your_email@youremail.com"

    1. start git in project directory:

    $ git init

    1. check project status

    $ git status

    1. add files for git tracking

    $ git add .

    or

    $ git add -u
    (remove deleted files)

    1. take a snapshot of the tracked files

    $ git commit

    or

    $ git commit -m "comments about the commit"

    1. check info about the commits

    $ git log

    1. check branchs in the project, at the beginning there will only be one, the master

    $ git branch

    1. create a new branch called authorization

    $ git branch authorization

    1. change to the new branch

    $ git checkout authorization

    1. Do the merge from branch authorization with the branch master
      Note: We should be in the master branch

    $ git merge authorization

    1. Now we can delete the authorization branch

    $ git branch -d authorization

    1. Create tags

    $ git tag -a v1.4 -m 'my version 1.4'

    1. Show all tags
      $ git tag
      v0.1
      v1.3
      v1.4@


  • Don't forget
    @git merge --no-ff@
    ff stands for fast-forward.
    for merging topic branches when the dev hasn't advanced yet (or hotfix branches when the master hasn't advanced).

    and of course
    @git rebase@
    usually when you push to a remote repo which has advanced and you don't want to merge but ff.

    I suggest
    http://nvie.com/posts/a-successful-git-branching-model/

    What might be helpful, too, here's my general .gitignore:
    @# OS Related:

    *~
    Thumbs.db
    desktop.ini
    .DS_Store

    Qt Related:

    build-release/
    build-debug/
    -build--Release/
    -build--Debug/
    .pro.user
    Makefile*
    moc_.cpp
    qrc_
    .cpp
    ui_*.h
    *.log
    *.qch
    *.qm
    *.ts
    *.autosave
    *.moc

    Compilation Binaries:

    *.o
    *.ar
    *.gz
    *.bz2
    *.xz
    *.tar
    *.a
    *.so
    *.lib
    *.dll
    *.exe@
    more specialized gitignores are in subdirs where necessary.

    My .gitattributes is
    @* text=auto

    *.cpp text
    *.h text
    *.txt text
    *.html text
    *.xml text
    *.css text
    *.sh text
    *.py text

    *.png binary
    *.jpeg binary
    *.jpg binary
    *.bmp binary@
    (prevents windows users from messing up newlines with their crazy \r\n)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.