Refference: https://git-scm.com/docs/git-reset Recommend: http://marklodato.github.io/visual-git-guide/index-zh-cn.html 本节主要讲版本回退,按照笔者自己的理解,可以分为两个类别: 远程版本回退 本地版本回退 远程版本和本地版本同时回退 git reset - 重置当前版本到指定的状态 命令 git reset [-q] [] [--] ... git reset (--patch | -q) [] [--] [...] git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [] 描述 git reset [<mode>] [<commit>] 重置当前分支的HEAD到指定的版本(这里commit改为commit-id更为合适),根据指定的模式mode可能会更新暂存区(index)和工作区。默认模式为mixed。 –soft 不改变暂存区和工作区,但是重置当前版本库到指定的版本。这就相当于所有改变了的文件处于待提交状态(Changes to be committed)。 –mixed 回退到指定的版本,暂存区也回退到指定版本,但是工作区不变(相对于回退版本,所有改变的文件都处于未标记为提交的状态),并且会显示待提交的文件。 –hard 重置版本库、暂存区以及工作区到指定的版本。在工作区中所有提交的文件都会被丢弃。 例子 撤销add操作 $ git add examples.txt $ git reset add之后,暂存区已经改变。所以撤销add操作就是重置暂存区的数据。使用git reset命名默认的模式,即可重置暂存区。 撤销commit操作(远程版本回退,本地仓不变) $ git commit … $ git reset –soft HEAD^ $ edit $ git commit -a -c ORIG_HEAD 如果commit之后发现提交不完整或有错误等,可以回退commit操作之后,对文件进行修改制作,再执行commit操作 撤销commit操作(远程版本以及本地版本同时回退) $ git commit … $ git reset –hard HEAD~3 本地和远程仓库都会指定的版本HEAD~3(HEAD~3表示回退到前3个版本),所以hard选项要慎用! 撤销单个文件的commit $ git...

read more


[toc] Gerrit配置 1 Gerrit修改背景颜色 1.1 方法及步骤 cd /review_site/etc vim gerrit.config [theme] backgroundColor = FCFEEF textColor = 000000 trimColor = D4E9A9 selectionColor = FFFFCC topMenuColor = D4E9A9 changeTableOutdatedColor = F08080 [theme "signed-in"] backgroundColor = FFFFFF [theme "signed-out"] backgroundColor = 00FFFF 重启gerrit 1.2 tips 使用双引号,不适用单引号,单引号重启gerrit会出错 2 Gerrit权限 gerrit中权限控制是基于群组的. 每个用户有一个或者多个群组, 访问权限被赋予这些群组.访问权限不能赋予个人用户. 2.1 系统组 gerrit系统默认自带群组 Anonymous Users Change Owner Project Owners Registered Users 组别 内容 Anonymous Users 所有用户都是匿名用户,都继承Anonymous Users所有访问权限. change Owner 访问权限在Change范围内有效 Project Owners 访问权限在Project范围内有效 Registered Users 所有在页面上登录成功的用户都会自动注册成gerrit用户 3. Gerrit冲突 3.1 merge conflict 解决方法: cd ~/projects/pan #切换到pan项目 git branch #查看分支情况 git checkout master #选择分支 git fetch origin #fetch与pull的区别,自己再搜吧~ git rebase origin/master #查看有“CONFLICT (content): ”的地方,手工解决冲突后,下一步...

read more


FNV哈希算法全名为Fowler-Noll-Vo算法, 是以三位发明者Glenn Fowler, Landon Curt Noll, Phong Vo的名字组合命名,最早在1991年提出。 算法优点 FNV能快速hash大量数据并保持较小的冲突率,它的高度分散使它适用于hash一些非常相近的字符串,比如URL,hostname等。 算法描述 相关变量: @hash : 返回值,一个n位无符号整数 @offset_basis : 初始的哈希值 @FNV_prime : FNV用于散列的质数 @octet_of_data : 8位数据 FNV-1 hash = offset_basis foreach octet_of_data in hash_data{ hash = hash * FNV_prime hash = has xor octet_of_data} return hash FNV-1a hash = offset_basis foreach octet_of_data in hash_data{ hash = hash xor octet_of_data hash = hash * FNV_prime } return hash FNV_PRIME取值 32bit : FNV_PRIME = 2^24 + 2^8 + 0x93 = 16777619 64bit : FNV_PRIME = 2^40 + 2^8 + 0xb3 = 1099511628211 128bit: FNV_PRIME = 2^88 + 2^8 + 0x3b = 309485009821345068724781371

read more


test.xml <?xml version="1.0" encoding="utf-8"> <root> <name>test</name> <info> <age>18</age> <sex>F</sex> </info> </root> 读操作 pugi::xml_document doc; pugi::xml_parse_result result = doc.load_file("test.xml"); pugi::xml_node node_root = doc.child("root"); pugi::xml_node node_name = node_root.child("name"); char_t *name_text = node_name.text().as_string(); for(pugi::xml_node node = node_root.child("info").first_child(); node; node = node.next_sibling()){ std::count << node.text() << std::endl; } pugi::xml_node node_info = node_root.child("info"); pugi::xml_node node_age = node_info.child("age"); int age = node_age.text().as_int(); 写操作 pugi::xml_document doc; pugi::xml_node node_root = doc.append_child("root"); // declare pugi::xml_node node_pre = doc.prepend_child(pugi::node_declaration); node_pre.append_attribute("version") = "1.0"; node_pre.append_attribute("encoding") = "utf-8"; // comment pugi::xml_node comment = node_root.append_child(pugi::node_comment); comment.set_value("Just for test!"); pugi::xml_node node_name = node_root.append_child("name").text().set("test"); pugi::xml_node node_info = node_root.append_child("info") pugi::xml_node node_age = node_info.append_child("age").text().set(18); pugi::xml_node node_sex = node_info.append_child("sex").text().set("F");...

read more


检测函数是否存在 假如要检测printf()这个函数是否存在 说明:     check_library_exists( )       检测系统库是否提供函数*function*,检测结果保存在*variable*中。但是这个函数并不能判定任何系统同文件中声明的函数, 仅能判断在链接是能找到的函数。如果想要判断任意头文件中声明的函数,可以考虑使用check_symbol_exists() include(CheckFunctionExists) check_function_exists(printf HAVE_PRINTF) 检测结果会保存在HAVE_PRINTF中 检测头文件是否存在 说明: check_include_file(include variable)     @include : name of include file @variable: variable to return result   check_include_files(includes variable)         @includes : list of files to include @variavle : variable to return result include(CheckIncludeFiles) check_include_files(inttypes.h HAVE_INTTYPES) check_include_files("sys/time.h;sys/time.h" HAVE_SYS_TIME) 检测符号(标识符)是否存在 说明:     check_symbol_exists( )       检测标识符是否作为函数,变量或宏存在。     检测在给定的头文件*files*中是否存在标识符*symbol*,并把结果保存在*variable*中。指定的文件列表用半角分号隔开(“test1.h;test2.h”)     如果头文件*files*中把标识符*symbol*作为宏定义了,可以认为这个标识符是有效可用的;如果头文件*files*中把标识符*symbol*作为函数或变量声明了,那么链接的时候能够获取到,才会认为这个标识符是有效可用的;如果这个标识符是一个类型或枚举值,它是不能被识别的(可以考虑使用CheckTypeSize或CheckCSourceCompiles)。如果检测用C++完成,则可考虑使用check_cxx_symbol_exists()。 include(CheckSymbolExists) check_symbol_exists(ENAMETOOLONG errno.h HAVE_ENAMETOOLONG) check_symbol_exists(__FUNCTION__ "" HAVE_FUNCTION) 检测库是否存在 说明: check_library_exists(library function location variable) @library : the name of library you are looking for @function : the...

read more