git:安装和配置
站内链接:
Install at Linux
注意: key 仅仅适用于 git 路径.
Install
1 | # Ubuntu |
Environment Variables
建议: git config –help
List:
1 | # 查看所有的可配置项 |
User and Email: 用于设置提交代码时的默认用户名/邮箱.
1 | # global |
Color:
1 | # 所有的终端默认着色 |
Editor:
1 | # 设置默认编辑器, 在git -m时默认调用该路径的程序 |
Configure File Location
1 | # 所有用户共用,通过git config --system 来设置 |
例如~/.gitconfig 的配置如下:
1 | # This is Git's per-user configuration file. |
Install at Windows
Install
git 安装的时候可以选择类 UNIX 的操作,之后启动 git 命令行时某些操作类似 shell。
PS:注意,Git-2.9.2-64-bit.exe 版本无需再设置 git 的路径,但是必须使用内置的终端启动 git 的命令行。
Configure
PS:git 自带的命令行操作和 Linux 上的操作其实一模一样。
User and Password:
1 | # 用户名和密码, 此时会在C:\Users\bamboo目录下面生成.gitconfig文件 |
Key:
1 | # 实际目录: C:\Users\bamboo\.ssh |
Git Export
basic
导出 git 项目下的原始内容,不包含版本控制信息,export git project, use archive command.
1 | # Chapter 1 -- archive to special directory |
Summary
统计 git export 过程中的信息: git export –sumary
Ignore
Syntax
1 | /: 表示递归, 其中build/表示忽略build文件夹 |
Global ignore
默认配置:/.gitignore_global/.gitignore’
手动配置全局:git config –global core.excludesfile ‘
Ignore File
1 | # 忽略特定文件(所有成员共享,.gitignore) |
Ignore local change(在版本控制中的文件)
1 | # 对特定的文件忽略本地修改(ignore the content change.) |
Ignore untrack file
自动的获取当前本地仓库中的 untrack file, 并自动加入到 gitignore 中
1 | echo "$(git status --porcelain | grep '^??' | cut -c4-)" >> .gitignore |
Alias
另见oh-my-zsh说明.
见~/.oh-my-zsh/plugins/git/git.plugin.zsh 文件说明
Command
Command :git config –global -e 或者 直接编写~/.gitconfig 文件.
Configure
1 | [alias] |
Advinse
建议直接使用 bash 的 alias 功能, 默认情况下, .on-my-zsh/plugins/git/git.plugin.zsh 中就存在一份非常完美的”别名命令”.
Test
参考 ssh 命令说明:
Note: 注意, 仅仅适用于 git 协议, 而非 https 协议, 关于<git 协议>
github
测试是否配置成功
1 | # 正常测试 |
coding
1 | # 正常 |
gitlab
1 | # 测试特定端口 |