# Git
下载地址:[https://git-for-windows.github.io/](https://git-for-windows.github.io/)
git --version 查看git版本号
liunx下安装git
unbuto系统 :
apt -get install git
CentOs系统
yum install git
git config --global user.name (用户名)
git config --global user.email (邮箱)
全局设置(不管在那个文件夹下面都能使用git命令)
git init 初始化当前工作区(必须)
当前工作目录下生产一个.git文件 若没有打开文件夹设置
显示隐藏的文件夹或驱动
git status 查看是否有需要被提交或管理的内容
~~~
git config --global user.name "mir.cheng"
git config --global user.email "5377978+mircheng_l@user.noreply.gitee.com"
~~~
git add . 将工作区所有的文件文件夹添加到暂存区中
git commit -m "注释内容" 提交到版本库
Git hub 官网地址:[https://github.com](https://github.com)
~~~
git remote add origin https://github.com/China-zerosafter-programmer/Laravel.git
连接github 远程仓库
origin 别名
master 分支
-u 建立本地master分支与远程的master分支关联
git push -u origin master
将本地内容推送到远程仓库
~~~
~~~
liunx系统下
cd ~/.shh
windows下
ssh-keygen -t rsa -C "注释内容"
直接回车确认文件
复制id_rsa_pub里面的内容
到github网站sestings里面SSH and GPG keys
添加新的秘钥
~~~
~~~
团队协作
进入仓库 sestings
Collaboratos 合作者
将需要的合作者github用户名添加到合作者
~~~
~~~
版本回退
git log
git log --pretty=online
一行版本显示
git reset --hard (版本号)
版本重置回退
git reflog
操作记录
git branch
查看所有分支
git branch 分支名
添加分支
git checkout 分支名
切换分支
git checkout -b 分支名
添加并切换分支
git merge 分支名
合并分支
git clone 仓库地址
克隆远程仓库项目
git push -u origin master
git fetch
查看服务器有哪些分支更新并拉去到本地
git diff
查看是否有冲突
~~~