github公開鍵構成-ローカルアップロードコード

2487 ワード

初めて使うときはgithubアカウントを登録する必要があります.https://github.com/maso53
 
コードをローカルにアップロードするには
1.鍵ペアの生成
 
ssh-keygen

 2.鍵ペアのコピー
 
 
maso@Mac~/.ssh$cd ~/.ssh/  ;  cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFlOgMf/q/4FDO3GSmehrulichs9U6ZsB6XSl5BIpiurCvHFnrkYu/7+v47mK4DHLfPKXZMcoCBYJPS8WY2R4oQLAQ/3y7IPDacjh0pfnLtsaEItfWz4tmm3z9SEwMJxILKctPvjP4+DaUH08ppIeuVd03Z5dwJ2S8UE5d2wWriqnhq53Lau0J2hNxusHZ6pjtYHrXjRVoUydelLAQjxvcL7CqFTt5Z2kEadcCmsurEkH0VEvnHJVoaRhH3e/CJPOXdBDpdgkhrokBenxFG6TqhcEITiq7hOk7FucF/uX9WRNtNv8YRNP9pncjD/WZa2obuaozqia065FmZOy47XWt [email protected]

3.githubアカウントにログインし、アカウント設定の場所にローカルで生成された公開鍵を追加する
 
 
4.正常に追加されたことを確認
 
maso@Mac~/.ssh$ ssh -T [email protected]
Warning: Permanently added the RSA host key for IP address '192.30.252.129' to the list of known hosts.
Hi maso53! You've successfully authenticated, but GitHub does not provide shell access.

  5.ローカルコードをアップロードし、ローカルディレクトリに進みます.
 
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin [email protected]:maso53/mybatisTest.git
git push -u origin master

Counting objects: 3, done.
Writing objects: 100% (3/3), 203 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:maso53/mybatisTest.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin

 
この一歩は間違っているかもしれない.
maso@localhost/data/git/crmWeb$git push -u origin master
To [email protected]:maso53/crmWeb.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:maso53/crmWeb.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解決策
git pull origin master

 
6.git共通コマンド
git  add  <filename>
git commit -m "comment"
git push -u origin master