- 使用 git diff 命令可以查看工作区与暂存区之间的差异。
- 使用 git diff 命令可以查看工作区与指定版本之间的差异。
- 使用 git diff --cached 命令可以查看暂存区与当前 HEAD 指针指向版本之间的差异。
- 使用 git diff --cached 命令可以查看暂存区与指定版本之间的差异。
- 使用 git diff -- 可以查看特定文件在工作区与暂存区之间的差异。
- 使用 git diff -- 可以查看特定文件在工作区与指定版本之间的差异。
- 使用 git diff --cached -- 可以查看特定文件在暂存区与当前 HEAD 指针指向版本之间的差异。
- 使用 git diff --cached -- 可以查看特定文件在暂存区与指定版本之间的差异。
Last active
April 2, 2019 03:00
-
-
Save sursir/e5f261d5661090d434d03877c47c4b28 to your computer and use it in GitHub Desktop.
Git git diff log reset revert to
foo bar
| |
* *
\ /
base
|
*
|
init
command | 效果 | 集合 |
---|---|---|
git diff foo bar | git diff init-foo -> init-bar | A U B |
git diff foo..bar (double dot) | git diff base-foo -> base-bar | A U B - A n B |
git diff foo...bar (triple dot) | git diff base -> base-bar | B - A B - A n B |
command | 效果 | 集合 |
---|---|---|
git log foo bar | git log init-foo -> init-bar | A U B |
git log foo..bar (double dot) | git log base -> base-bar | B - A B - A n B |
git log foo...bar (triple dot) | git log base-foo -> base-bar | A U B - A n B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 具体可看 | |
http://fle.github.io/git-tip-keep-your-branch-clean-with-fixup-and-autosquash.html | |
### 通过 fixup 与 rebase autosquash 来自动将不必要的bug commit 来抹掉 | |
# automatically marks your commit as a fix of a previous commit | |
git commit --fixup <commit> | |
# 交互式 自动合并 fixup 提交 <commit> 为 最早的fixup-2 即 想要的提交-1,不给commit 会自动fixup | |
# automatically organize merging of these fixup commits and associated normal commits | |
git rebase -i --autosquash <commit> |
当处于一个大型git
仓库目录下时,zsh
将会变的非常慢。
oh-my-zsh 会自动检查仓库的状态, 函数:git_prompt_info()
and parse_git_dirty()
其中主要拖慢速度的还是parse_git_dirty
,此函数会来检查工作区未提交内容。
我们只需要在当前仓库下禁用此功能就行
# git config --add oh-my-zsh.hide-status 1 # 连分支名都会禁用,不推荐添加此项,因为此项无影响
git config --add oh-my-zsh.hide-dirty 1 # 禁用工作区检查
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################### | |
### git | |
##################### | |
# 可删除一个远程分支 | |
git push origin :a | |
# 配置 push 的默认行为 (具体可参见 git 默认行为) | |
git config --global push.default simple | |
* nothing - push操作无效,除非显式指定远程分支,例如git push origin develop(我觉得。。。可以给那些不愿学git的同事配上此项)。 | |
* current - push当前分支到远程同名分支,如果远程同名分支不存在则自动创建同名分支。 | |
* upstream - push当前分支到它的upstream分支上(这一项其实用于经常从本地分支push/pull到同一远程仓库的情景,这种模式叫做central workflow)。 | |
* simple - simple和upstream是相似的,只有一点不同,simple必须保证本地分支和它的远程 upstream分支同名,否则会拒绝push操作。 | |
* matching - push所有本地和远程两端都存在的同名分支。 | |
# 删除一个分支 | |
git branch -D a | |
# check 一个分支 并切换 | |
git checkout -b a | |
# 使用默认工具 解决冲突 | |
git mergetool | |
# git fetch && git merge 理想情况下(无冲突) 会有一次自动的 merge 信息 | |
# 否则 则需要 解决冲突 然后 commit (有冲突的情况下 必须使用 commit) | |
##### 回滚到某个版本 | |
1. | |
git reset --hard 4 暂存区改变 工作区改变 领先提交 | |
git reset --soft 8 暂存取不变 工作区不变 提交恢复 | |
(git checkout master) | |
git commit -m 'Reverted 5 6 7 8' 提交暂存区 | |
(暂存区工作区保持一致) | |
2. | |
git checkout 4 (要回滚到的版本) | |
git reset --soft <your_branch_name> | |
git checkout master (切换回分支<your_branch_name> 而不是commit) | |
git commit -m "Revert 5 6 7 8" | |
##### 打包最近一次提交的改动文件 | |
git archive -o update.zip HEAD $(git diff --name-only HEAD^) | |
##### 导出某个版本的某个文件 | |
git show COMMIT:FILE | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment