创建本地仓库
#创建本地文件夹MyAlgoTest,自己的工程名字也叫MyAlngoTest
cd ./Workspace/Code/MyWork/MyGitHub/
mkdir MyAlgoTest
cd MyAlgoTest
#git init 处理自己的本地仓库
git init
在自己的本地仓库中添加文件
echo "My algorithm test space" > README.txt
将自己新添加的文件加入自己的本地仓库中
#git add 只是将文件加入到了本地仓库,并没有提交
git add README.txt
#git commit 才是真正的将自己的代码提交到本地仓库
git commit README.txt -m "Add My README.txt"
注意此时在 commit 时可能会报一下错误:
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
这个错误的原因是你们又设置你的用户名与邮箱,按照提示设置就好,设置完重新commit。
到此我们的就在建好了我们的本地工程,然后是如何将本地工程与github上相关联起来。
关联GitHub仓库
创建自己的GitHub仓库
在你自己github的Your repositores页面中有个“New”的按钮,点击此按钮,就可以创建你自己的GitHub工程仓库了。
本地仓库与GitHub仓库关联
将github的远程仓库加入的你本地的remote相关的配置中。
git remote add origin https://github.com/${你github账号}/MyAlgoTest.git
将本地仓库的变化提及到到远程仓库
git push -u origin master