# git上传代码至GitHub
一、准备工作
有属于自己的GitHub,本地电脑有git。https://npm.taobao.org/mirrors/git-for-windows/
二、操作
GitHub:
创建一个repository
git本机安装
创建本地仓库
git init --建仓 git add * --添加代码到本地仓库 git commit -m "first commit" --提交本地缓存 (首次使用会提示:please tell me who you are) git config --global user.name "xxx@xxx.com(你的github邮箱)" git config --global user.email "你的github用户名"(敲完之后,继续上面的commit这一步) git remote add origin https://github.com/xxxx.git --提交到远程github上(后面的地址,就是之前配置的repository地址) git push -u origin master --push到master分支
注意:
1.要是cmd窗口看到提示以下这两个信息 $ git config --global user.name "xxx" $ git config --global user.email xxx.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.首次操作过程中需要登录就按提示输入账号名和密码
# git克隆代码
选取一个文件夹 git init git clone http://github地址