服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - 编程技术 - git文件管理心得分享

git文件管理心得分享

2022-02-23 17:0434677946 编程技术

本篇文章主要通过实例步骤给大家分享了在学习git文件管理时的心得,有兴趣的朋友学习参考下吧。

untraked file 未跟踪的文件,通常为新建立的文件

traked file 通常为建立索引之后的文件

ignored 被忽略的文件,这类型的文件通常在一个文件列表中。维护这个列表的文件在版本库根目录名字为 .gitignore
初始化版本库,保证刚创建状态

?
1
2
3
4
5
6
7
8
9
10
11
huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master)
$ ls
hello
huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master)
$ ls -a
./ ../ .git/ hello
huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master)
$ rm -rf .git/ hello
huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo
$ git init
Initialized empty Git repository in C:/Users/huawei/Desktop/git-repo/.git/

创建文件查看文件类型,发现为untraked file未被跟踪的文件

?
1
2
3
4
5
6
7
8
9
10
huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master)
$ echo "hello world" > hello
huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master)
$ git status
On branch master
No commits yet
Untracked files:
 (use "git add <file>..." to include in what will be committed)
  hello
nothing added to commit but untracked files present (use "git add" to track)

被跟踪的文件通常为建立索引之后的文件,可以通过git ls-files -s查看。至于被忽略的文件可以看下面的演示,将文件名写入到.gitignore文件即可

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master)
$ git status
On branch master
nothing to commit, working tree clean
huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master)
$ echo "a" > a
huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master)
$ git status
On branch master
Untracked files:
 (use "git add <file>..." to include in what will be committed)
  a
nothing added to commit but untracked files present (use "git add" to track)
huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master)
$ echo a >> .gitignore
huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master)
$ git status
On branch master
Untracked files:
 (use "git add <file>..." to include in what will be committed)
  .gitignore
nothing added to commit but untracked files present (use "git add" to track)

.gitignore文件语法

#开头的行用于注释

空行会被注释

目录名末尾用反斜线(/)标记

包含shell通配符,如*。例 debug/32bit/*.o

起始地感叹号用于取反模式

原文链接:http://blog.csdn.net/qq_34677946/article/details/78834246

延伸 · 阅读

精彩推荐