1. 列出 git控制的文件:
git ls-tree -r master --name-only
git ls-files include/linux/list.h --error-unmatch include/linux/list.h
$ touch new-file <pre name="code" class="plain">$ git ls-files new-file --error-unmatch error: pathspec 'new-file' did not match any file(s) known to git. Did you forget to 'git add'?或者:
$ git status include/linux/list.h On branch master nothing to commit, working directory clean
$ touch new-file $ git status new-file On branch master Untracked files: (use "git add <file>..." to include in what will be committed) new-file nothing added to commit but untracked files present (use "git add" to track)或者:
$ git status --porcelain new-file ?? new-file3. 查找已经修改但是没有提交的文件
$ git checkout M Makefile M include/linux/memory.h
$ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: Makefile modified: include/linux/memory.h Untracked files: (use "git add <file>..." to include in what will be committed) file new-file no changes added to commit (use "git add" and/or "git commit -a")
$ git diff diff --git a/Makefile b/Makefile index 256d744..3fdb0b9 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ PATCHLEVEL = 10 SUBLEVEL = 28 EXTRAVERSION = NAME = TOSSUG Baby Fish - +11111 +22222 # *DOCUMENTATION* # To see a list of typical targets execute "make help" # More info can be located in ./README diff --git a/include/linux/memory.h b/include/linux/memory.h index 85c31a8..c698b72 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -19,7 +19,7 @@ #include <linux/compiler.h> #include <linux/mutex.h><pre name="code" class="plain">$ git checkout Makefile include/linux/memory.h
$ git checkout M Makefile M include/linux/memory.h
$ git checkout Makefile include/linux/memory.h
$ git checkout $
* git revert HEAD 撤销前一次 commit
* git revert HEAD^ 撤销前前一次 commit
* git revert commit-id
revert 会产生历史记录
7 git log
$ git log --pretty=oneline --abbrev-commit 22ee5b8 Revert "Revert "update Makefile with -gdwarf-2 -g3 flag"" 19f6c54 Revert "update Makefile with -gdwarf-2 -g3 flag" 0178fc5 update Makefile with -gdwarf-2 -g3 flag 9ad4424 intial kernel code
8change file permissions
git update-index --chmod=+x file