前言
作为一个程序员,我们往往希望把自己呕心沥血书写的代码展示给更多人看,得到更多的肯定,在谷歌Google code关闭下载服务后,我们大部分选择的则是GitHub,在windows上,这一些列大多属于可视化操作,我们也就不一一列觉,在Mac os上很多时候需要我们去通过终端控制并完成这一切。
前期准备
-
1.登录GitHub账号,创建仓库!

-
2.填写仓库信息

上图中,填写相应信息后点击create即可
Repository name: 仓库名称
Description(可选): 仓库描述介绍
Public, Private : 仓库权限(公开共享,私有或指定合作者)
Initialize this repository with a README: 添加一个README.md
gitignore: 不需要进行版本管理的仓库类型,对应生成文件.gitignore
license: 证书类型,对应生成文件LICENSE
创建完成后,你会看到如下图的页面

开始上传
-
1.打开终端 输入
cd /Users/yongqiangwei/Desktop

进入桌面后,我们需要将仓库克隆至本地 git clone + 仓库地址
git clone https://github.com/YongQiangWei/GitDemo.git

克隆成功后,你会发现在你的Mac桌面多了一个文件夹 GitDemo
-
2.将你需要上传的代码文件全部复制到GitDemo中

-
3.进入GitDemo
终端输入
cd /Users/yongqiangwei/Desktop/GitDemo
执行以下代码:
git add .
别忘记后面的.,此操作是把Test文件夹下面的文件都添加进来
git commit -m "提交信息" (
“提交信息”里面换成你需要,如“first commit”)
git push -u origin master
此操作目的是把本地仓库push到github上面,此步骤需要你输入帐号和密码


到这里,我们已经将需要上传的代码已经成功上传至GitHub仓库

网友评论