GitでBitbucketの初期設定

Gitをインストールしたので早速Bitbucketを使ってみる。
自分の名前とメールアドレスを設定します。

git config --global user.name "xxx"
git config --global user.e-mail "xxx@xxx.xxx"

日本語ファイル名の文字化けの回避設定をしておく。

git config --global core.quotepath false

Bitbucket用に鍵を作っておく

ssh-keygen -t rsa -C "t61ubuntu"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/t61/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/t61/.ssh/id_rsa.
Your public key has been saved in /home/t61/.ssh/id_rsa.pub.

これで/home/t61/.ssh/に鍵が出来たので(t61は僕のユーザー名です)
確認してみます。

ls /home/t61/.ssh/
id_rsa  id_rsa.pub  known_hosts

鍵がありました。

cat /home/t61/.ssh/id_rsa.pub

で中身を表示してコピーしておく。

そしてBitbucket側のSSH接続を設定する。
Bitbucketにログインする。
https://bitbucket.org/account/user/ユーザー名/ssh-keys/
にアクセスして「鍵を追加」する。


labelにわかりやすい名前をつけて先ほどコピーした鍵を貼り付ける。

これで繋がるはず。

適当なディレクトリを作る

sudo mkdir gittest

※この時点でBitbucket内で適当なリポジトリを作っておく。
今回は「test2018」というリポジトリを作っておいた。

git clone git@bitbucket.org:プロジェクト名/test2018.git

コマンドを打つと、パスフレーズを聞かれるので入力。
「空のリポジトリですけど」って言われる。

つまり繋がったので作業開始できる!

Git, Linux

Posted by bistro