Git的必要配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| shuaige@DESKTOP-54PIQAR MINGW64 /d/Edge $ git config -l diff.astextplain.textconv=astextplain filter.lfs.clean=git-lfs clean -- %f filter.lfs.smudge=git-lfs smudge -- %f filter.lfs.process=git-lfs filter-process filter.lfs.required=true http.sslbackend=schannel core.autocrlf=true core.fscache=true core.symlinks=false pull.rebase=false credential.helper=manager credential.https://dev.azure.com.usehttppath=true init.defaultbranch=master user.email=eminemgcxwlp@gmail.com user.name=GCXWLP
shuaige@DESKTOP-54PIQAR MINGW64 /d/Edge $ git config --system --list diff.astextplain.textconv=astextplain filter.lfs.clean=git-lfs clean -- %f filter.lfs.smudge=git-lfs smudge -- %f filter.lfs.process=git-lfs filter-process filter.lfs.required=true http.sslbackend=schannel core.autocrlf=true core.fscache=true core.symlinks=false pull.rebase=false credential.helper=manager credential.https://dev.azure.com.usehttppath=true init.defaultbranch=master
shuaige@DESKTOP-54PIQAR MINGW64 /d/Edge $ git config --global --list user.email=eminemgcxwlp@gmail.com user.name=GCXWLP
|
Git的工作原理
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| +-----------------+ git push +-----------------+ | Remote Directory| <--------------------- | History | +-----------------+ +-----------------+ ^ ^ | | | git pull | git reset | | v | +-----------------+ git commit +-----------------+ | History | <--------------------- | Stage(Index) | +-----------------+ +-----------------+ ^ | git add files | | v +-----------------+ | Working Directory| +-----------------+ ^ | git checkout | | v +-----------------+ | Stage(Index) | +-----------------+
|
基础流程
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| shuaige@DESKTOP-54PIQAR MINGW64 /d/Edge/gittest $ git init Initialized empty Git repository in D:/Edge/gittest/.git/
shuaige@DESKTOP-54PIQAR MINGW64 /d/Edge/gittest (master) $ ls
shuaige@DESKTOP-54PIQAR MINGW64 /d/Edge/gittest (master) $ touch whatcanisay.md
shuaige@DESKTOP-54PIQAR MINGW64 /d/Edge/gittest (master) $ vim whatcanisay.md
shuaige@DESKTOP-54PIQAR MINGW64 /d/Edge/gittest (master) $ git status On branch master
No commits yet
Untracked files: (use "git add <file>..." to include in what will be committed) whatcanisay.md
nothing added to commit but untracked files present (use "git add" to track)
shuaige@DESKTOP-54PIQAR MINGW64 /d/Edge/gittest (master) $ git add .
shuaige@DESKTOP-54PIQAR MINGW64 /d/Edge/gittest (master) $ git status On branch master
No commits yet
Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: whatcanisay.md
shuaige@DESKTOP-54PIQAR MINGW64 /d/Edge/gittest (master) $ git commit -m "牢大,坐跑车上学就是爽" [master (root-commit) 8c62890] 牢大,坐跑车上学就是爽 1 file changed, 1 insertion(+) create mode 100644 whatcanisay.md
shuaige@DESKTOP-54PIQAR MINGW64 /d/Edge/gittest (master) $ git status On branch master nothing to commit, working tree clean
|
.gitignore
有些时候我们不想把某些文件纳入版本控制中,比如数据库文件、临时文件、设计文件等。
在主目录下建立 .gitignore 文件,此文件有如下规则:
基本规则
忽略空行或以 # 开头的行
支持 Linux 通配符
* :匹配任意多个字符
? :匹配单个字符
[abc] :匹配方括号内的任意一个字符
{string1,string2,...} :匹配可选的字符串之一
以感叹号(!)开头的模式表示例外
- 表示不忽略该文件或目录(即使之前匹配了忽略规则)。
以 / 开头表示只忽略项目根目录下的文件或目录
以 / 结尾表示忽略目录
1 2 3 4 5 6
| *.txt !lib.txt /temp build/ doc/*.txt
|
git分支相关