将本地仓push到github的完整基本操作:
- 本地创建一个空的文件夹 作为你本地仓库的工作空间 (git bash内使用 “mkdir 文件夹名称” 命令 或者 任意方式)
>> mkdir test - 进去这个仓库文件夹 并创建本地仓
>> cd test
>> git init - 登录你的github主页,在上面创建一个仓库
- 在本地的git bash中,对远程仓库(github上的仓库)进行关联:
>> git remote add origin git@github.com:你的用户名/你的github仓库名.git - 将本地仓库和github仓库进行合并
>>git pull origin master - 将本地修改进行添加 (可一次进行多次add)
>>git add 你要提交的文件 - 进行提交
>>git commit -m "提交说明" - 推送到远程仓库
>>git push origin master
在做上面这些之前:
- 在git bash中 ,生成ssh文件:
>> ssh-keygen -t rsa -C "你的账户名" - 在用户主目录里找到 .ssh 目录,里面 有 id_rsa 和 id_rsa.pub 两个文件,这两个就是SSH Key的秘钥,id_rsa 是私钥,不能泄露出去, id_rsa.pub 是公钥。
- 登陆GitHub,打开“Account settings”,“SSH Keys”页面: 然后,点“Add SSH Key”,填上Title,在Key文本框里粘贴 id_rsa.pub 文件 的内容。