Git-1
首先声明账户
git config --global user.name xxxx
git config --global user.email xxxxx@qq.com
创建文件夹后建立仓库
git init 建立仓库
git status 查看状态
Untracked files 还没跟踪
添加到本地仓库
git add . 添加当前目录文件
git add index.txt 添加指定文件
git commit -m “init” 提交
git commit -m ‘add read.txt’ -m后面是注释
总结
先造文件
再看状态 发现新文件,还没跟踪
添加进来
工作区
a.php , b.php
工作区add一下存到暂存区
再commit 一下来到版本库
修改文件
需要先add index.txt
再git commit -m ‘modify’
删除文件
git rm read.txt
git commit -m “del read.txt”
Git-2
推送项目
git push https://gitee.com/xxxx/first-one.git master
git config --system --unset credential.helper 重置用户名和密码
别名
git remote add origin https://gitee.com/xxxx/first-one.git
同步远程仓库
git push -u origin master
git remote -v
git remote rm origin
Git-3
来到其他盘,模仿其他用户
克隆
git clone https://git.oschina.net/xxxx/first-one.git
拉取项目
git pull first-one master
git add .
git commit -m “”
git push origin master
查看日志
git log
单行显示
git log --pretty=oneline
倒退版本
git reset --hard HEAD^^^^^
HEAD代表最新的版本 ^代表往前退五个版本
建议用版本号切换
git reset --hard 2580d(版本号)
git reflog 历史操作
http://blog.sina.com.cn/s/blog_6aebf01f0101fugz.html
https://www.aliyun.com/jiaocheng/11268.html
Git-4
分支管理
查看分支
git branch
创建test分支
git branch test
切换分支
git checkout test
合并分支
切到master 再合并
git merge test
删除分支
git branch -d test
git checkout -b test
远程仓库
查看远程仓库
git remote -v
删除远程仓库别名
git remote remove 远程库名
添加远程库别名
git remote add 别名 地址
git push origin master
配置公钥
配ssh地址
创建公钥
ssh-keygen -t rsa -c email(邮件) 一路回车
在c盘下找到.ssh文件中找到公钥 -pub
复制,在远程仓库建立公钥,粘贴