From 50e52a7544f7d542c933a662e3bf076c44561aec Mon Sep 17 00:00:00 2001 From: xueweihan <595666367@qq.com> Date: Wed, 20 Jul 2016 23:20:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=AE=8C=E6=88=90=EF=BC=8CTO?= =?UTF-8?q?DO=EF=BC=9A=E6=A3=80=E6=9F=A5=E3=80=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=8E=92=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 159 ++++++++---------------------------------------------- 1 file changed, 22 insertions(+), 137 deletions(-) diff --git a/README.md b/README.md index 70aadb6..a2d6881 100644 --- a/README.md +++ b/README.md @@ -233,15 +233,19 @@ git ls-files --others -i --exclude-standard ``` ## 强制删除untracked的文件 -清空工作区untracked的文件 +可以用来删除新建的文件。如果不指定文件文件名,则清空所有工作的untracked文件。`clean`命令,**注意两点**: +1. clean后,删除的文件无法找回 +2. 不会影响tracked的文件的改动,只会删除untracked的文件 + ```sh -git clean -f +git clean -f ``` ## 强制删除untracked的目录 -清空工作区untracked的目录 +可以用来删除新建的目录,**注意**:这个命令也可以用来删除untracked的文件。详情见上一条 + ```sh -git clean -df +git clean -df ``` ## 重命名分支 @@ -265,62 +269,31 @@ git bundle create git clone repo.bundle -b ``` -## Ignore one file on commit (e.g. Changelog). -```sh -git update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog -``` - -## Stash changes before rebasing +## 执行rebase之前自动stash ```sh git rebase --autostash ``` -## Fetch pull request by ID to a local branch +## 从远程仓库根据ID,拉下某一状态,到本地分支 ```sh git fetch origin pull//head: ``` - -__Alternatives:__ -```sh -git pull origin pull//head: -``` - -## Show the most recent tag on the current branch. +## 展示当前分支的最近的tag ```sh git describe --tags --abbrev=0 ``` -## Show inline word diff. +## 详细展示一行中的修改 ```sh git diff --word-diff ``` -## Don’t consider changes for tracked file. -```sh -git update-index --assume-unchanged -``` - -## Undo assume-unchanged. -```sh -git update-index --no-assume-unchanged -``` - -## Clean the files from `.gitignore`. +## 清除`.gitignore`文件中记录的文件 ```sh git clean -X -f ``` -## Restore deleted file. -```sh -git checkout ^ -- -``` - -## Restore file to a specific commit-hash -```sh -git checkout -- -``` - ## 展示所有alias和configs. ```sh git config --list @@ -336,31 +309,6 @@ git status --ignored git log Branch1 ^Branch2 ``` -## reuse recorded resolution, record and reuse previous conflicts resolutions. -```sh -git config --global rerere.enabled 1 -``` - -## Open all conflicted files in an editor. -```sh -git diff --name-only | uniq | xargs $EDITOR -``` - -## Count unpacked number of objects and their disk consumption. -```sh -git count-objects --human-readable -``` - -## Prune all unreachable objects from the object database. -```sh -git gc --prune=now --aggressive -``` - -## Instantly browse your working repository in gitweb. -```sh -git instaweb [--local] [--httpd=] [--port=] [--browser=] -``` - ## 在commit log中显示GPG签名 ```sh git log --show-signature @@ -377,104 +325,41 @@ git config --global --unset git checkout --orphan ``` -## Extract file from another branch. +## 展示任意分支某一文件的内容 ```sh git show : ``` -## List only the root and merge commits. -```sh -git log --first-parent -``` - -## Change previous two commits with an interactive rebase. -```sh -git rebase --interactive HEAD~2 -``` - -## List all branch is WIP -```sh -git checkout master && git branch --no-merged -``` - -## Find guilty with binary search -```sh -git bisect start # Search start -git bisect bad # Set point to bad commit -git bisect good v2.6.13-rc2 # Set point to good commit|tag -git bisect bad # Say current state is bad -git bisect good # Say current state is good -git bisect reset # Finish search - -``` - -## Bypass pre-commit and commit-msg githooks -```sh -git commit --no-verify -``` - -## List commits and changes to a specific file (even through renaming) -```sh -git log --follow -p -- -``` - -## Clone a single branch +## clone下来指定的单一分支 ```sh git clone -b --single-branch https://github.com/user/repo.git ``` -## Create and switch new branch +## 创建并切换到该分支 ```sh git checkout -b ``` - -__Alternatives:__ -```sh -git branch && git checkout -``` - -## Ignore file mode changes on commits +## 关闭Ignore文件的功能 ```sh git config core.fileMode false ``` -## Turn off git colored terminal output -```sh -git config --global color.ui false -``` - -## specific color settings -```sh -git config --global -``` +## 展示本地所有的分支的commit +最新的放在最上面 -## Show all local branches ordered by recent commits ```sh git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/ ``` -## Find lines matching the pattern (regex or string) in tracked files -```sh -git grep --heading --line-number 'foo bar' -``` +## 在commit log中查找相关内容Search Commit log across all branches for given text +通过grep查找,given-text:所需要查找的字段 -## Clone a shallow copy of a repository -```sh -git clone https://github.com/user/repo.git --depth 1 -``` - -## Search Commit log across all branches for given text ```sh git log --all --grep='' ``` -## Get first commit in a branch (from master) -```sh -git log master.. --oneline | tail -1 -``` - -## 把暂存区的内容放到工作区中 +## 把暂存区的指定file放到工作区中 ```sh git reset ```