@K1999
2017-02-07T01:58:14.000000Z
字数 1639
阅读 1781
管理工具
这里用msysgit 下载地址
登录github,点击New repository
Repository name:Hello-World
$ git config --global user.name "YourName"
$ git config --global user.email "YourE-mail"
$ git config --lis
$ mkdir ~/Hello-World #在本地建对应的repository
$ cd ~/Hello-World/
$ git init
#Initialized empty Git repository in C:/Users/Eaton-PC/Hello-World/.git/
$ touch README.md
$ git add README.md
$ git commit -m 'first commit' #提交记录说明
$ git remote add origin https://github.com/YourName/Hello-World.git
$ git push origin master
$ cd ~/. ssh #检查本机的ssh密钥
如果有此文件夹,说明不是第一次使用,执行下面的操作,清理原有ssh密钥。
$ mkdir key_backup
$ cp *_rsa* key_backup
$ rm *_rsa*
$ ssh-keygen –t rsa –C "YourName@xxx.com"
这里的邮箱地址YourName@xxx.com是自己的邮箱地址,回车之后会让你输入保存密钥的文件名,这里输入id_rsa。最后会得到id_rsa和id_rsa.pub两个文件,前者是私钥,后者是公钥。
添加私钥到ssh:
$ ssh-add id_rsa
如果报错:Could not open a connection to your authentication agent.
先执行一下:
$ ssh-agent bash
再执行 ssh-add id_rsa。
将公钥添加到github中,Personal settings中选择SSH keys,在New SSH Key中Title填写本机的名字,Key是把公钥文件的内容贴进来。
$ ssh git@github.com
如果出现下面内容,说明连接成功了
PTY allocation request failed on channel 0
Hi YourName! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
$ git clone https://github.com/Eaton18/Hello-World.git
后面的链接是项目在github中的地址。
假如本地已经存在了这个项目,而仓库中又有更新,获取更新:
$ git fetch origin //取得远程更新,这里可以看做是准备要取了
$ git merge origin/master //把更新的内容合并到本地分支/master
本地编辑了项目之后,将当前版本上传到仓库中
$ git add *
$ git status //可以看到我们对哪些文件做了修改
$ git commit -m 'update project' #提交记录说明
$ git push origin master
$ git status
$ git rm hehe/hello.txt
$ git commit -m 'del txt'
$ git push origin master