Saturday, February 7, 2015

git 简易操作指南

首先 download git 软件http://msysgit.github.io/
在github上新建repository
在git bash命令行下

【建立账号】

$ git config --global user.name "John Doe"

$ git config --global user.email johndoe@example.com


【新建git项目】在某目录下

$ git init

【克隆项目】

$ git clone git://github.com/schacon/grit.git

【check status】

$ git status

【commit】可以copy文件进来

$ git commit (-v)  (:wq 保存退出)

$ git commit –m “write message” (不弹出编辑界面)

$ git commit –am “write message” (修改的不用重新add)

【remove files】

$ rm file.py (硬盘删除linux,unstaged)

$ git rm (-f) file.py (登记删除,同时硬盘删除)

然后git push 可以推送
git push origin master
可以把 master 换成你想要推送的任何分支


$ git log (查看commit历史)
git reset --hard   可强制下载pull


$ git branch name (只是建立分支,仍在master分支上)

$ git checkout name (转到分支上,转分支时文件自动改变!!)






No comments:

Post a Comment