第一次真正使用git提交代码,还是有很多问题,后面进行补充学习,先掌握最基本的命令
git init
使用当前目录作为仓库
git init
我的方法:
我想设置为仓库的目录 F:\phpstudy\PHPTutorial\WWW\code
进入 WWW 目录,选中 code 文件夹并右键,点击 Git Bash Here
~~~~
git clone
克隆有两个方式
git clone git@github.com:yanbin314/findAnswer.git
git clone https://github.com/yanbin314/findAnswer.git
将文件放到仓库目录下 再cd进入findAnswer目录
在这时可以使用 git pull 来证明确实创建成功
$ git pull
Already up to date.
~~~~
git add .
将文件上传至缓存区
~~~~
git status -s
查看项目的当前状态
$ git status -s
A "\346\211\213\346\234\272\347\253\257/(\351\237\251)index.html"
A "\346\211\213\346\234\272\347\253\257/README.md"
A "\346\211\213\346\234\272\347\253\257/css/reset.css"
A "\346\211\213\346\234\272\347\253\257/css/style.css"
A "\346\211\213\346\234\272\347\253\257/index.html"
A "\346\211\213\346\234\272\347\253\257/index.php"
A "\346\211\213\346\234\272\347\253\257/jquery.js"
A "\346\211\213\346\234\272\347\253\257/js/js.js"
A "\346\211\213\346\234\272\347\253\257/js/myAjax.js"
A "\346\211\213\346\234\272\347\253\257/loading.js"
A "\346\211\213\346\234\272\347\253\257/\357\274\210\351\237\251\357\274\211index.php"
~~~~
git commit
第一次要设置用户名和邮箱
git config --global user.name "xxx"
git config --global user.email xxx@xxx.com
git commit -m "代码提交信息"
然后使用 git status 如果已经提交完成 会出现这几行
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
~~~~
git push
推到主目录上
git push origin master