LoginSignup
51
38

More than 5 years have passed since last update.

Xcodeのプロジェクトに.gitignoreを追加する。

Last updated at Posted at 2017-04-30

Xcodeに.gitignoreを追加するにあたり、初歩的なところで困ったので投稿

1 .gitignoreを作成する

作成場所: Xcodeプロジェクトのディレクトリ直下
ターミナルで移動し、下記のコマンドを実行
$ touch .gitignore

2 Fiderで.始まりのファイルを見れるようにする

ターミナルで下記のコマンドを実行
$ defaults write com.apple.finder AppleShowAllFiles true
$ killall Finder

3 .gitignoreを編集する

作成した.gitignoreをテキストエディタで開き、任意の内容を書き込む
自分はgithub/gitignoreの内容をコピペ

4. すでにコミットしたファイルをgit管理対象外にする

自分は.gitignoreを作成する前に、gitの管理対象外にしたいファイルをコミットしていたため本手順を実施。一度すべてのファイルを管理対象外にする。
ターミナルでプロジェクトのディレクトリに移動し、下記のコマンドを実行
git rm -r --cached .
git add .

5 Xcodeからコミット

Xcodeのメニューから[Source Control] > [Commit...]
たぶんターミナルで実行しても良いと思う。.gitignoreが効いていることを確認しやすかったので自分はXcodeで実施

Xcodeからだと上手くコミットできていなかったため、コマンドで実行。コミット前にgit statusで変更ファイルを確認。
git status
git commit -m "fix .gitignore"

51
38
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
51
38