Git : a version control system
Github: a code sharing and collaboration platform
Git
commit
User-created checkpoint called Commit, and you should commit a message each time a commit is create(make one commit per logical change.
( git message备注的约定俗成)git commit
:将cache(stage area)中的修改提交到repository中git log
: 查看version的修改日志 (show a list of all commits)git log --graph --oneline branch1 branch2
可以查看两个branch的区别,越往上的越是最近commit的
git diff
:查看同一文件不同版本的区别(参数为同一文件的不同id号,可以用git log查看,不加参数时比较working space和cache中同一文件的区别, git diff --staged查看cache和repository同一文件的区别) (diff -u 比较两个不同文件的区别)
git clone
:下载整个repository(所有版本)。(并且自动在本地设置remote建立起远程与本地的关系,可以用 git remote查看)git check
: return to a previous version of your files. 可以用来查看历史version的运行效果。(参数为id,可用git log查看)(也可以输入git branch +分支名字选择branch)git init
:在某一个路径下初始化该路径为git repository (初始化后包含.git源文件)git status
:可以查看哪些文件没有git add、最近一次的git操作git add/reset +fname
: 添加文件到cache/删减cache(缓存空间)中的文件git branch
: 不加参数的时候查看有什么branch,git branch + name
创建新分支, 然后通过git checkout name选择。- remote branch表示别人创建的branch
- 'head' means current commit, any branches, it wnd detached head isn't included in aon't show up in git log.
当出现detached head warning的时候可以用git checkout -b +new_branch_name
创建新分支
修改一个文件后,还没用git add保存到cache空间(staging area) 时,用git status 查看会出现 “Changes not staged for commit"
git merge + branch1 + branch2
: 合并branch2到branch1- git merge --abort可以用来取消遇到confict 的merge
- git merge 成功后,用
git branch -d + branch2
删除第二分支,然后可以从汇总来查看原本第二分支的版本 (只删除了分支的label,分支的内容没删除)
Github
git remote add +short_name +URL
:(先进入本地已经git init的需要关联github的文件路径)关联github上面的repository(short_name为远程库的在当地的reference,URL为远程库的链接)git push +short_name +branch_name
:将本地的某个分支上传到github中。(如果本地和remote在父节点产生不同的两个分支,那就在github中自动merge他们)

push只能上传分支所能到达的点.git pull +short_name +branch_name
: 将github的某个分支下载到本地中。(如果本地和remote在父节点产生不同的两个分支,那就在本地中自动merge他们)fork
: cloning repo from github to github. 克隆别人github的repo到自己的github,然后Git clone 到本地。
git fetch
:

Udacity lesson 4 第十九集解释 fetch, pull, remote (origin)和merge (origin & remote) 的关系。