GIT Tips (To be continued)
来源:互联网 发布:泰鲁斯·托马斯数据 编辑:程序博客网 时间:2024/05/18 13:29
1. 列出 git控制的文件:
git ls-tree -r master --name-only
2. 判断一个文件是否在git控制里:
git ls-files include/linux/list.h --error-unmatchinclude/linux/list.h
$ touch new-file<pre name="code" class="plain">$ git ls-files new-file --error-unmatcherror: pathspec 'new-file' did not match any file(s) known to git.Did you forget to 'git add'?或者:
$ git status include/linux/list.hOn branch masternothing to commit, working directory clean
$ touch new-file$ git status new-fileOn branch masterUntracked files: (use "git add <file>..." to include in what will be committed)new-filenothing added to commit but untracked files present (use "git add" to track)或者:
$ git status --porcelain new-file ?? new-file3. 查找已经修改但是没有提交的文件
$ git checkout MMakefileMinclude/linux/memory.h
$ git status On branch masterChanges 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: Makefilemodified: include/linux/memory.hUntracked files: (use "git add <file>..." to include in what will be committed)filenew-fileno changes added to commit (use "git add" and/or "git commit -a")
4. 显示对没提交的文件做的修改:
$ git diffdiff --git a/Makefile b/Makefileindex 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 ./READMEdiff --git a/include/linux/memory.h b/include/linux/memory.hindex 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
#include <linux/notifier.h>-+AAAAAAAAAAA #define MIN_MEMORY_BLOCK_SIZE (1UL << SECTION_SIZE_BITS) struct memory_block {5. 撤销没有提交的修改:
$ git checkout MMakefileMinclude/linux/memory.h
$ git checkout Makefile include/linux/memory.h
$ git checkout $
6. 撤销提交操作:
* git revert HEAD 撤销前一次 commit
* git revert HEAD^ 撤销前前一次 commit
* git revert commit-id
revert 会产生历史记录
7 git log
$ git log --pretty=oneline --abbrev-commit22ee5b8 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 flag9ad4424 intial kernel code
8change file permissions
git update-index --chmod=+x file
0 0
- GIT Tips (To be continued)
- GIT Command (To Be Continued)
- 2004(to be continued)
- To be Continued
- to be continued
- 散装笔记 ...to be continued
- 回忆moblin ...to be continued
- 各种方法......to be continued
- Defect Patterns (To be continued)
- Matlab拾零(to be continued)
- Cpp拾零(to be continued)
- Zookeeper 介绍 [To Be Continued]
- Rust : Pointer......to be continued
- notes on effective C++ (to be continued)
- 设计模式 c# 学习(-) to be continued..
- 常用正则(to be continued)
- 梳状滤波器(to be continued)
- .bash_profile和.bashrc说明--to be continued
- 用node-webkit开发多平台的桌面客户端
- windows修改用户目录名
- 字符串
- 折磨人的iab测试(in-app-billing) (二) 消费类
- apktool + keytool + jarsigner
- GIT Tips (To be continued)
- json解析
- struts2文件上传
- apk的签名文件(两次Hash+加密)
- [Microsoft][ODBC Sql Server Driver]无效的连接 错误解决
- 2014年12月23日
- textfield之shouldChangeCharactersInRange函数探究
- 题目1457:非常可乐
- 圣诞树成长历程(2)