【开发环境系列】关于Git,你需要知道的事
来源:互联网 发布:latex mac 编辑:程序博客网 时间:2024/06/15 21:17
如何使用Git
如何安装Git
如何配置Git
- 用户信息
git config --global user.name "yourname"git config --global user.email "yourname@youremail_server.com"
- 文本编辑器
git config --global core.editor code
- 差异分析工具
git config --global merge.tool vimdiff
- 查看配置信息
git config --list
如何创建仓库
- 初始化仓库
git init newrepo
- 写入缓存
git add .
- 撤销缓存
git reset HEAD
- 提交所添加的文件/文件夹
git commit -m "初始化项目版本"
git commit -a rem 提交缓存git commit -am "初始化项目版本"
- 查看提交/缓存
git status
- 查看提交之后是否有修改的详细信息信息
git diff 尚未缓存git diff --cached rem 已缓存git diff HEAD rem 已缓存/未缓存git diff --stat 摘要非整个diff
- 拷贝项目
git clone <repo>git clone <repo> <directory>
- 移除文件
git rm <file>git rm -f <file>git rm -cached <file>git rm -r *
- 移动/重命名文件
git mv <file-name> <file-new-name>
- 回滚到指定的版本
git reset --hard id
- 强制提交
git push -f origin master
如何分支管理
- 创建分支
git branch <branch_name>
- 切换分支
git checkout <branch_name>
- 创建并切换分支
git checkout -b <branch_name>
- 合并分支
git merge [branch_name]
- 合并冲突
git add <conflict_file>
- 删除分支
git branch -d <branch_name>
- 列出分支
git branch
如何查看提交历史
- 列出详尽的提交历史
git log
- 列出简介的提交历史
git log --oneline
- 列出提交历史的时序
git log --reverse --oneline
- 查找指定用户的日志
git log --author=yourname --online -5
- 查找制定指定期间的日志
git log --before={3.weeks.ago} --after={2017-12-01} --no-merges
标签
- 创建带注解的标签
git tag -a <tag> <series>
- 查看标签
git taggit log --decorate
如何使用远程仓库
- 配置验证
ssh-keygen -t rsa -C "yourname@youremail_server.com"
- 创建本地库
mkdir local_repocd local_repo/echo "# 本地库 Git 测试" >> README.mdlsgit initgit add README.mdgit commit -m "添加 README.md 文件"
- 添加远程库
git remote add [shortname] [url]
git remote add origin remote_repo
- 删除远程库
git remote rm [alias]
git remote rm origin
- 推送到远程库
git push [alias] [branch]
git push -u origin master
- 查看当前的远程库
git remotegit remote -v rem 显示详细信息
- 提取远程仓库
git fetch [alias] rem 下载新分支git merge [alias]/[branch]rem 合并分支
git fetch origingit merge origin/master
阅读全文
0 0
- 【开发环境系列】关于Git,你需要知道的事
- 【开发环境系列】关于conda管理Python开发环境,你需要知道的事
- 【开发环境系列】关于Docker配置Python开发环境,你需要知道的事
- 【脚本语言系列】关于Python开发环境搭建,你需要知道的事
- 【脚本语言系列】关于Python集成开发环境,你需要知道的事
- 关于git你需要知道的
- 【脚本语言系列】关于Python系统管理,你需要知道的事
- 【脚本语言系列】关于Python容器,你需要知道的事
- 你需要知道的git
- 关于 Git 你需要知道的一些事情
- [译] 关于 Git 你需要知道的一些事情
- [译] 关于 Git 你需要知道的一些事情
- [译] 关于 Git 你需要知道的一些事情
- 关于 Git 你需要知道的一些事情
- 关于 Git 你需要知道的一些事情
- 关于git你需要知道这些
- 【脚本语言系列】关于Python调试报错,你需要知道的事
- 【脚本语言系列】关于Python数值计算NumPy, 你需要知道的事
- bzoj3000 Big Number
- 判断EditText输入的是数字还是英文还是汉字
- 数据结构复习之路-线性表
- FZU
- Less学习笔记1
- 【开发环境系列】关于Git,你需要知道的事
- [深度学习论文笔记][arxiv 1711]Learning to Segment Every Thing
- Android SDK Manager 闪退
- Android 自定义圆形进度条
- centos 更换源之后yum下载失败
- Django学习(1)一首情诗
- python flask中HTTP方法methods=['GET','POST']
- python的callable()函数
- iptables小案例