Git Notes
# Git 学习笔记, 参考: Git Documentation
提交更改(about changes)
* 工作区, 暂存区, 版本库 (working directory, staging area, git repo)
* git status: 查询当前状态(check current status):
1. 文件跟踪情况(file trackings)
2. 文件未在暂存区的更改(changes for staged files)
3. 文件已存在与暂存区的更改(changes for unstaged files)
* git add: 1. 跟踪新文件(tracking new files)
2. 将文件放入暂存区(stage change to staging area)
3. 合并冲突文件(merge conflict)
4. 平时用 -A 已经足够( "-A" is enough for common usege case)
* git diff: 查看所未暂存的文件快照(check all snapshots of unstaged changes)
* --cache: 查看所有已经存放于暂存区的文件快照(check all snapshots of staged changes)
* git log -p "<file-path>": 查看文件的所有版本快照(check all versions changes of a specific file)
* git -m "<message>": 1. 提交更改(commit all staged changes)
2. -a 可选参数, 将未添加到暂存区的更改一并添加并提交( commit all staged and unstaged changes, equals combining "git add ." and "git commit -m"
*git commit --amend: 将更改提交到某一次已提交的更改( commit a change to a existing commit)
添加标签(add tag)
###### 标签可以用来建立新的分支(tag is used to create new branch at any time)
~~~
* git tag -a “
建立分支(about branch)
* git checkout -b <name>: 建立新的分支并切换到新的分支(create a new branch and change to it)
* git push origin <name>: 将新建立的分支上传至remote(push a new branch to remote reop
* 如何合并分支到 master:
1. git checkout master : change to master branch;
2. git merge <name> : merge a specifi branch to master;
3. git push origin master : push all changes include new merge to master branch on remote repo
blog comments powered by Disqus