1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

gitリポジトリの設定に関する備忘録 (SSH鍵設定・git config)

Posted at

前書き

最近PCを切り替える作業があり、使い始めの頃に設定したgitやssh周りの内容を忘れてしまっていました。。。
またPC切り替えがありそうな予感がするので、備忘録として残しておきます。

SSHの設定

複数のgitリポジトリにsshで接続する必要があったので、ホストを分けられるようにしてます。

.ssh/config
Host github.com # サブアカウント
  HostName github.com
  User git
  Port 22
  IdentityFile ~/.ssh/sub_id_rsa
  TCPKeepAlive yes
  IdentitiesOnly yes

Host bitbucket.org # 個人アカウント
  HostName bitbucket.org
  User git
  Port 22
  IdentityFile ~/.ssh/id_rsa
  TCPKeepAlive yes
  IdentitiesOnly yes

git config

globalとlocalでアカウントの設定を変える

.git/config
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
	precomposeunicode = true
[user]
	name = お名前
	email = メールアドレス

[remote "origin"]
	url = git@bitbucket.org:hoge/project.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?