Git repository initialize

个人能力有限,若有错误请批评指正!

转载请标明出处:http://www.cnblogs.com/wenhust/

为什么要上传SSH公钥?

你的git客户端可通过SSH协议访问git仓库托管网站,将你本地的SSH公钥上传到git仓库托管网站之后,每次执行git push/fetch自动使用SSH密钥认证SSH Keys配置不当访问远端代码库会报错。

如何产生SSH公钥及上传?

  1. 在Linux或Mac OS终端或Windows Git Bash, 执行ssh-keygen命令生成SSH公钥和私钥
ssh-keygen -t rsa

填写SSH密钥存放目录, 或直接回车存在在默认位置:

$HOME/.ssh/

输入SSH密钥的使用密码并记住,每次下载和上传时会用到此密码; 或直接回车不设置密码

  1. 查看并复制SSH公钥
cat ~/.ssh/id_rsa.pub
  1. 粘贴到填写框中, 添加保存即可

Command line instructions

Git global setup

git config --global user.name "Your Name"
git config --global user.email ""[email protected]"" 

Create a new repository

git clone ssh://xxx.git
cd YourProj
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Existing folder

cd existing_folder
git init
git remote add origin ssh://xxx.git git add . git commit -m "Initial commit" git push -u origin master 

Existing Git repository

cd existing_repo
git remote add origin ssh://xxx.git
git push -u origin --all
git push -u origin --tags

猜你喜欢

转载自www.cnblogs.com/wenhust/p/12421557.html
今日推荐