GItHub 上创建代码仓库 创建成功后,出现如下页面,展示该仓库的远程地址以及使用方法。
创建目录
$ mkdir -p git_origin进入目录并关联远程仓库
$ cd git_origin $ git clone [上图中远程仓库的地址-项目名为test_project] Cloning into 'test_project'... warning: You appear to have cloned an empty repository.确认拉取成功
$ ls test_project因为目前该项目为空仓库,创建文件并提交
$ cd test_project $ echo "# README" >> README.md $ git add . $ git commit -m "first commit" *** Please tell me who you are. ... fatal: unable to auto-detect email address这里并没有提交成功,还需要配置账户信息:
$ git config --global user.email "you@example.com" $ git config --global user.name "Your Name"配置后再次提交后,成功提交,自动生成 master分支,通过命令查看, * 代表目前所处的分支。
$ git branch * master目前本地仓库的代码已提交到本地的 master 分支,远程仓库还没有 readme.md 文件。
此处还需要输入 github 的账号和密码,才能成功提交。
提交成功后,刷新远程仓库页面,即可看到提交的代码。