openFrameworksプロジェクトをGitでバージョン管理
openFrameworksのプロジェクトをGitでバージョン管理しようとしたとき、どのファイルを追跡対象にすべきなのか迷っていたら下記のページに解説が載っていたのでメモ。
ofBook - Version control with Git
このページには他にもグラフィック関連だったりC++関連だったりの基礎的なところから充実した解説が載ってるので重宝しそうです。
手順
まずは普通にprojectGeneratorで空のプロジェクトを作成します。
次にプロジェクトフォルダへ移動してGitリポジトリを生成します。
$ git init
次に、.gitignoreファイルを作ります。
プロジェクトをビルドして生成されるバイナリファイルや、IDEの設定ファイル、OSによって生成されるバックアップファイル等は追跡不要なので、それらを.gitignoreに指定して追跡対象から除外します。
将来的にはprojectGeneratorで自動的に.gitignoreを作ってくれるようになる予定のようですが、現在は下記のページで公開されているテンプレートを使用すると良いでしょう。
github.com
内容はこんな感じで、binフォルダ以下のファイル(bin/dataフォルダを除く)、各IDEやOSごとの追跡不要ファイル拡張子などが指定してあります。
#.gitignore is a file which makes git ignore files which should # not go into version control in the first place # Questions? See # http://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository#Ignoring-Files # http://git-scm.com/docs/gitignore ########################### # ignore generated binaries # but not the data folder ########################### /bin/* !/bin/data/ ######### # general ######### [Bb]uild/ [Oo]bj/ *.o [Dd]ebug*/ [Rr]elease*/ *.mode* *.app/ *.pyc .svn/ *.log ######################## # IDE files which should # be ignored ######################## # XCode *.pbxuser *.perspective *.perspectivev3 *.mode1v3 *.mode2v3 # XCode 4 *.xccheckout xcuserdata/ # Visual Studio *.sdf *.opensdf *.suo *.pdb *.ilk *.aps ipch/ # Eclipse .metadata local.properties .externalToolBuilders # Android Studio .gradle /local.properties /.idea/workspace.xml /.idea/libraries ################## # operating system ################## # Linux *~ # KDE .directory .AppleDouble # OSX .DS_Store *.swp *~.nib # Thumbnails ._* # Windows # Image file caches Thumbs.db # Folder config file Desktop.ini # Android .csettings
基本的にはこれを使用し、必要があれば追記する形で問題ないでしょう。
/bin/data/以下の特定フォルダを追跡対象から除外したい場合
/bin/* !/bin/data/
となっているので、/bin/data/フォルダは追跡対象です。
ですが、/bin/data/フォルダはデバッグ用の画像を出力したりしたいときがあります。
その場合、例えば以下を加えることで特定のフォルダを追跡対象外にできます。
/bin/* !/bin/data/ /bin/data/export/
これで/bin/data/export/フォルダは追跡対象外となるので、Gitで追跡したくないファイルはここへ書き出すよう運用すればOKです。
あとは普通にGitを使用すれば良いでしょう。
$ git add . $ git commit -m "Initial commit"
IDEが生成するファイルって何のためのファイルなのか全然分からないんですよね〜。
テンプレート万歳!!