Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Git | excludeファイルにローカル環境だけ無視したいファイルを登録

概要

excludeファイルにローカル環境だけ無視したいファイルを登録

内容

.gitignoreはバージョン管理の対象外にしたいファイルを登録することができます。
登録した内容はリポジトリで管理し、共同で利用しているユーザーと共有出来ます。

しかし、ローカル環境のみ自分独自の設定内容を保持したいファイルがある場合で
.gitignoreでその状態を共有したくない場合があります。
そのような場合は

.git/info/exclude

にファイルを追加することでコミット対象外としつつ、他のメンバーと除外設定を
共有せずに済みます。

サンプル

myfile.txtというファイルがコミットされずに存在しています。
このファイルを.git/info/excludeに追記し、除外対象とした後に
git statusで確認を行います。

$git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       myfile.txt
nothing added to commit but untracked files present (use "git add" to track)
$git status | echo
$echo myfile.txt >> .git/info/exclude
$cat .git/info/exclude
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
myfile.txt
$git status
# On branch master
nothing to commit (working directory clean)
$

Ruby | pikでWindows環境に複数バージョンのRubyをインストール

概要

pikでWindows環境に複数バージョンのRubyをインストール

内容

前提

Ruby1.9.3インストール済み
・Ruby2.0.0をインストールする

pikインストール
gem install pik

C:\pikを作成しパスを通しておく

下記を実行

pik_install c:\pik

Ruby2.0.0のインストール
pik install ruby 2.0.0
Ruby2.0.0への切り替え
$ruby -v
ruby 1.9.3p0 (2011-10-30) [i386-mingw32]

$pik use 200

$ruby -v
ruby 2.0.0p195 (2013-05-14) [i386-mingw32]

せっかくなのでRuby2からの新フィーチャーであるパラメータ引数のサンプルコードを実行

# encoding: utf-8
def hoge(hage: 'hage', hige: 'hige', cnt: 1)
  puts hage*cnt + hige*cnt
end

hoge(hige: 'ひげ', hage: 'はげ')
hoge(hage: 'はげ', hige: 'ひげ', cnt: 2)

出力

はげひげ
はげはげひげひげ