Git 高级操作与技巧全解析
1. 代码修改与提交
在开发过程中,代码的修改和提交是常见操作。例如对main.c文件进行修改:
+++ b/main.c @@ -1,4 +1,5 @@ #include <stdio.h> +#include <stdlib.h> struct htentry { char *item; @@ -15,6 +16,12 @@ void ht_init(void) int main(int argc, char **argv) { + FILE *f; + + f = fopen(argv[1], "r"); + if (f == 0) + exit(-1); + /* * Print a histogram of words found in a file. * "Words" are any whitespace separated characters.修改完成后,需要进行提交操作。先对哈希表补丁进行git commit操作,然后对其余文件操作部分进行暂存和提交。在暂存操作时,对于 “Stage this hunk?” 问题,除了常见的提示选项(如[y,n,q,a,d,/,K,g,e,?]),还有延迟处理选项,可后续再决定暂存与否。
暂存操作可针对一个文件中的多个块,甚至多个文件中的多个块。将多个文件的更改合并暂存,可对每