【iPhone】XcodeプロジェクトをBitbucketで管理する
概要
XcodeのプロジェクトをgitとBitbucketで管理する。
BitbucketはプライベートRepositoryが無料でいくらでも利用できるので、外部に公開したくないソースなどを管理するのに便利。
*GithubではプライベートRepositoryが有料。
なので、外部に公開するソースはGithub、公開したくないソースはBitbucket、と使い分けるのが良い。
1. Bitbucketに登録する
下記URLより無料登録。
Githubのアカウントがある場合は連携することで簡単に登録できる。
Sign up for a Bitbucket account
2. BitbucketでRepositoryを作成
「Create」から新しいRepositoryを作成する。
このときに「This is a private repository 」をチェックすると外部に公開されないRepositoryを作成可能。
RepositoryページトップURLの末尾に「.git」と付けたものを後でXcode側で指定する。
例、「https://ユーザ名@bitbucket.org/ユーザ名/小文字のRepository名.git」
3. Xcodeの準備
Xcodeでプロジェクトを作成する際に「Create local git repository for this project」にチェックを付ける。
XcodeからCommitする。ファイル名の横に「M」と表示されている場合はCommitされていないということなのでCommitする。
Commitの仕方は、メニューから「File」-「Source Control」-「Commit...」
Commitする際にコメントを忘れないこと。コメントを入れないとエラーとなりCommitできない。
4. XcodeでBitbucketをRemote Repositoryに指定する
Xcodeのメニューから「Window」-「Organizer」を選択。
「Repositories」を選択。左メニューから「Remotes」を選択。
下部、「Add Remote」を選択し、Remote Nameにはbitbucketなど適当に入力。
Locationには、「2. Repositoryを作成」で作成したRepositoryのURLを入力。
URLの形式は、「https://ユーザ名@bitbucket.org/ユーザ名/小文字のRepository名.git」
入力したら、「Create」を選択。
「Username」と「Password」に、それぞれBitbucket登録時に設定したものを入力する。