http://gitref.cyj.me/zh/index.html
http://gitbook.liuhui998.com/index.html
使用 git add 添加需要追踪的新文件和待提交的更改, 然后使用 git status 和 git diff 查看有何改动, 最后用 git commit 将你的快照记录。这就是你要用的基本流程,绝大部分时候都是这样的。
git init -- 建立仓库
git add <file> = git commit -a -- 添加文件到缓存
git commit -m(注释) --allow-empty -- 记录缓存内容的快照
commit之后才算正式有了分支
提交前需要输入用户名,邮箱
git config --global user.name 'Your Name'
git config --global user.email [email protected]
git remote add [alias] [url] -- 添加一个新的远端仓库
git push [alias] [branch]-- 将本地commit的代码更新到远程版本库中
git pull [alias] [branch] -- 从远端仓库提取数据并尝试合并到当前分支
产生冲突时,<<<<<<< Head和========之间的部分是本次要提交的,=======和>>>>>>>是服务器上现在的
HelloGIT at client <<<<<<< HEAD Update readme file at local and submit to test reslove the confict. hubert ======= Update readme file at local and submit to test reslove the confict testsdfsdfsdfsdfsdfsd >>>>>>> 239b3c2cedd978fdd9f567ce6920fc17e7110daa
git status -s(简短模式) -- 查看文件在工作目录与缓存的状态
撤销合并: $ git reset --hard HEAD
$ git log -p
查看日志
$ git log --stat
如果用--stat
选项使用'git log',它会显示在每个提交(commit)中哪些文件被修改了, 这些文件分别添加或删除了多少行内容.
$ git log --pretty=short
$ git log --pretty=short
格式化日志
先将未提交的修改暂存起来,接着清除所有改动,使之与没修改时一样。
若你正在开发功能 A,又需立即去开发功能 B。A 的代码正改到一半,未认真整理,你不想立即提交。此时……请呼叫 stash ~。
$ git stash
$ git stash pop