git
配置
git提供了一个git config工具,专门用来配置货读取相应的工作环境变量。
/etc/gitconfig:系统配置,使用 –system参数
~/.gitconfig:用户配置,使用 –global参数
用户和电子邮件
1 2
| git config --global user.name "your name" git config --global user.email "your email"
|
文本编辑器
1
| git config --global core.editor "editor name"
|
查看信息
1 2 3
| git config --list git config <config name> git log
|
创建仓库
1 2
| git init git init <dir>
|
提交
1 2 3
| git add <file> git commit -m 'init project version' git status -s
|
拷贝
1
| git clone <repo> <directory>
|
取消
1
| git reset HEAD <file name>
|
删除
1 2 3
| git rm <file> git rm -f <file> git rm --cached <file>
|
移动
分支
1 2 3 4 5
| git branch git branch <branch name> git checkout <branch name> git merge <branch name> git branch -d <branch>
|
标签
1 2
| git tag -a "tag name" git tag
|
远程仓库
1 2 3 4 5
| git remote add [short name][url] git remote git fetch git push [store] [branch] git remote rm [store]
|
生产ssh-key
1 2
| ssh-keygen -t rsa -C "your email" ssh -T git@github.com
|
搭建git服务器
安装git
1 2
| groupadd git useradd git -g git
|
创建证书登录
1 2
| mkdir .ssh touch .ssh/authorized_keys
|
初始化git仓库
克隆仓库
1
| git clone git@localhost:/仓库地址
|