一, 注册 Github 账号
1. 先注册一个账号, 注册地址: https://github.com/
2. 登录后, 点击 start a project
3. 创建一个 repository name, 输入框随便取一个名字 (不要用中文)
4. 点 Create repository 创建成功, 如下
二, 安装 git
1.git 是本地客户端管理代码的一个工具, 下载地址: https://git-scm.com/download/win
2. 下载到本地电脑后, 一路傻瓜式安装 Next->Next->-Next
3. 安装完成后, 本地随便建个文件夹, 如 github, 在文件地址栏输入 cmd
4. 打开 dos 界面后输入 git, 看到如下界面说明安装成功
三, 本地仓库
1. 回到之前的 github 界面, 下面有几个指令告诉我们如何把本地代码上传:
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/merryd/test.git
git push -u origin master
2. 在上面创建的 github 文件目录放需要上传的代码, 然后按照上面的步骤开始操作
第一步: git init -- 建仓
第二步: git add * -- 添加代码到本地仓库 (* 是代码添加全部更新的)
第三步: git commit -m "first commit" -- 提交到本地缓存 ("引号里面是说明提交了什么东西")
(首次使用会提示: please tell me who you are)
如果看到上面的提示, 就在 cmd 里面继续敲这两行:
>git config --global user.name "xxx@xxx.com(你的 github 邮箱)"
>git config --global user.email "你的 github 用户名"(敲完之后, 继续上面的 commit 这一步)
第四步: git remote add origin https://github.com/merryd/test.git-- 提交到远程 github 上 (后面的地址, 就是之前配置的 repository 地址)
第五步: git push -u origin master --push 到 master 分支
3. 代码上传成功后, 如图所示
四, 遇到问题与解决方案注意: 初次使用的话, 在输入上面指令过程中会遇到以下几个问题:
1. 要是 cmd 窗口看到提示以下这两个信息
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
解决办法: 按上面的提升, cmd 窗口接着输入
>git config --global user.name "这里是你的 github 用户名"
>git config --global user.email xxx@xxx.com(你的邮箱)
2. 提交到远程时候, 提示:
fatal: remote origin already exists.
解决办法: 删除远程 git 仓库
>git remote rm origin
3. 首次操作过程中需要登录就按提示输入账号名和密
来源: http://www.bubuko.com/infodetail-2485267.html