bitbucketでチーム開発を始める手順


用意するもの

  • mac (windowsの場合はGit bashを入れておくと良い)
  • VSCode

bitbucketのアカウントを作成する

こちらよりアカウントを各自作成する
https://bitbucket.org/

ssh公開鍵、秘密鍵の作成

下記のコマンドで公開鍵、秘密鍵が~/.ssh/配下に作成されます。

cd ~/.ssh/
ssh-keygen -t rsa -f filename

configの設定

~/.ssh/configに以下記述し保存

Host bitbucket.org
  User git
  Port 22
  HostName bitbucket.org
  IdentityFile ~/.ssh/filename # filenameは秘密鍵を指定
  TCPKeepAlive yes 
  IdentitiesOnly yes
  ForwardAgent yes
Host ホスト名
HostName ホスト
User ログインユーザ
IdentityFile 秘密鍵
Port ポート(デフォルトは22)
TCPKeepAlive 接続状態を保持する場合はyes
IdentitiesOnly IdentityFileが必要な場合はyes
ForwardAgent ssh-agentを利用する

bitbucketに登録

  • view profile > 設定 > 鍵を追加
  • label は 鍵の名を追加
  • keyは以下を実施したうえ貼り付け
cat ~/.ssh/filename.pub | pbcopy .

bitbucketからローカルPCにClone

あらかじめ管理者でリポジトリを作成した上、以下のコマンドでclone

git clone [email protected]:team_name/project.git

書き込みができるか確認

ファイルの書き込みができるかcloneしたフォルダ内で確認

touch test.txt
git add .
git ci -m "first commit"
git push origin master

bitbucket > プロジェクト > リポジトリ
コミットが表示されていれば初期設定完了