自整理(以下 从头开始):
背景:已注册好GitHub账号 管理公有项目不要钱 私有是需要交钱的
第一步:创建远程仓库


点击Create repository 之后 看到仓库创建完成 剩下的就是同步代码到上面

第二步:配置SSH key 做到只能在指定电脑上面进行上传与修改
终端操作:
ssh-keygen -t rsa -C youremail@xxx.com // 你注册 GitHub 账号时的邮箱
然后一路回车 需要输入密码的地方可以不输入
pbcopy < ~/.ssh/id_rsa.pub 复制公钥(用于在GitHub上面设置)
回到GitHub 设置公钥


这样就添加完成了 但是是灰色的 如图

回到电脑终端 输入命令行
ssh -T git@github.com 建立连接
然后回到GitHub 刷新添加公钥界面 发现变绿了

第三步:上传代码
终端操作:
cd 到你的项目目录
git init 将项目目录变成可以使用github管理的仓库
git add . 将项目中所有文件添加到本地仓库
git commit -m "firstCommit" 添加的文件提交到仓库 添加说明

再次回到GitHub 复制下面的

回到终端 操作
git remote add origin git@github.com:DeepSeaGhost/GitHubTest.git //记得填你自己的仓库 将本地仓库与远程仓库关联起来
git pull origin master //pull 一下正常情况 会出现以下界面

Git 在 pull 或者合并分支的时候有时会出现这个界面。如不需要填写,按3、4步操作:
1.按 i 进入 insert 模式
2.修改最上面那行黄色合并信息(可以不修改)
3.按"Esc"
4.输入 :wq ,回车即可(注意:冒号在英文键盘模式下输入)
如果没有出现 并且最后一行出现

试用 git pull origin master --allow-unrelated-histories 这个命令
最后一步 push代码到远程仓库
git push -u origin master

删除远程仓库

点击后 跳转界面 滚动到最下面

上传代码用到命令
cd 到指定目录
git init 将指定目录变成可以使用git管理的仓库
git add . 将所有文件添加到仓库
git commit -m "first commit" 添加到仓库 提交说明
git remote add origin git@github.com:DeepSeaChost/GitHubTest.git 连接本地与远程仓库
git pull origin master(此命名没用 使用 git pull origin master --allow-unrelated-histories) pull操作
git push -u origin master 上传代码 push
提示:以上描述仅仅是一路畅通无阻 配置相关操作 无详细说明 详细资料请点 http://www.jianshu.com/p/29e3719862b9
网友评论