git 安装
1. 安装官网 https://git-scm.com/
2. 配置
git config --global user.name "yourname"
git config --global user.email "youremail@163.com"
查看配置 git config --list
3. sourceTree 安装官网 https://www.sourcetreeapp.com/
git 仓库
1. 初始化版本库
git init
生成.git 文件
2. 添加文件到版本库
git add
git add --help (查看帮助文档 q 退出文档)
git add -A (提交全部文件)

git reset HEAD demo.txt (从仓库中移除)

git checkout -- demo.txt (删除未提交变更)
git commit
git commit -m "commit info"
3. 查看仓库状态
git status
Git 工作流

1. 查看历史提交版本
git log
2. 回退到某一版本
git reset --hard 2d62d28ea69a8ed0f69ae3daf0749c0382f2e197
3.删除某文件
git rm -f test.php
远程仓库
1. 创建 SSH key 到github
ssh-keygen -t rsa -C "youremai@email.com"
cat id_rsa.pub

ssh -T git@github.com

2. 添加远程仓库

git remote add origin git@github.com:youname/youproject.git (设置远程仓库)
git pull origin master (拉取远程内容)
git push -u origin master (推送到远程仓库)
克隆仓库
1. git clone git地址
标签管理


分支管理
1. 创建分支
git branch feature/test1_branch (创建分支feature/test1_branch)
2. 分支列表
git branch
3. 切换分支
git checkout master (切换到master分支上)
4. 删除分支
git branch -d feature/test1_branch (删除分支)
5. 合并分支
git merge branch1
总结

网友评论