code manager tools git的使用;
git的使用
一.下载及安装:
1.下载:https://github.com
2.安装:
二.常用命令:
查看、添加、提交、删除、找回,重置修改文件
git help< command> # 显示command的help
git show # 显示某次提交的内容 git show $id
git co --< file> # 抛弃工作区修改
git co . # 抛弃工作区修改
git add< file> # 将工作文件修改提交到本地暂存区
git add . # 将所有修改过的工作文件提交暂存区
git rm< file> # 从版本库中删除文件
git rm< file> --cached # 从版本库中删除文件,但不删除文件
git reset< file> # 从暂存区恢复到工作文件
git reset -- . # 从暂存区恢复到工作文件
git reset --hard # 恢复最近一次提交过的状态,即放弃上次提交后的所有本次修改
git ci< file> git ci . git ci -a # 将git add, git rm和git ci等操作都合并在一起做 git ci -am "some comments"
git ci --amend # 修改最后一次提交记录
git revert< $id> # 恢复某次提交的状态,恢复动作本身也创建次提交对象
git revert HEAD # 恢复最后一次提交的状态
查看文件diff
git diff< file> # 比较当前文件和暂存区文件差异 git diff
git diff< $id1>< $id2> # 比较两次提交之间的差异
git diff< branch1>..<branch2> # 在两个分支之间比较
git diff --staged # 比较暂存区和版本库差异
git diff --cached # 比较暂存区和版本库差异
git diff --stat # 仅仅比较统计信息
查看提交记录
git log git log< file> # 查看该文件每次提交记录
git log -p< file> # 查看每次详细修改内容的diff
git log -p -2 # 查看最近两次详细修改内容的diff
git log --stat #查看提交统计信息
tig
Mac上可以使用tig代替diff和log,brew install tig
Git 本地分支管理
查看、切换、创建和删除分支
git br -r # 查看远程分支
git br< new_branch> # 创建新的分支
git br -v # 查看各个分支最后提交信息
git br --merged # 查看已经被合并到当前分支的分支
git br --no-merged # 查看尚未被合并到当前分支的分支
git co< branch> # 切换到某个分支
git co -b< new_branch> # 创建新的分支,并且切换过去
git co -b< new_branch>< branch> # 基于branch创建新的new_branch
git co $id # 把某次历史提交记录checkout出来,但无分支信息,切换到其他分支会自动删除
git co $id -b< new_branch> # 把某次历史提交记录checkout出来,创建成一个分支
git br -d< branch> # 删除某个分支
git br -D< branch> # 强制删除某个分支 (未被合并的分支被删除的时候需要强制)
分支合并和rebase
git merge< branch> # 将branch分支合并到当前分支
git merge origin/master --no-ff # 不要Fast-Foward合并,这样可以生成merge提交
git rebase master< branch> # 将master rebase到branch,相当于: git co< branch>&& git rebase master&& git co master&& git merge< branch>
Git补丁管理(方便在多台机器上开发同步时用)
git diff > ../sync.patch # 生成补丁
git apply ../sync.patch # 打补丁
git apply --check ../sync.patch #测试补丁能否成功
Git暂存管理
git stash # 暂存
git stash list # 列所有stash
git stash apply # 恢复暂存的内容
git stash drop # 删除暂存区
Git远程分支管理
git pull # 抓取远程仓库所有分支更新并合并到本地
git pull --no-ff # 抓取远程仓库所有分支更新并合并到本地,不要快进合并
git fetch origin # 抓取远程仓库更新
git merge origin/master # 将远程主分支合并到本地当前分支
git co --track origin/branch # 跟踪某个远程分支创建相应的本地分支
git co -b< local_branch> origin/<remote_branch> # 基于远程分支创建本地分支,功能同上
git push # push所有分支
git push origin master # 将本地主分支推到远程主分支
git push -u origin master # 将本地主分支推到远程(如无远程主分支则创建,用于初始化远程仓库)
git push origin< local_branch> # 创建远程分支, origin是远程仓库名
git push origin< local_branch>:<remote_branch> # 创建远程分支
git push origin :<remote_branch> #先删除本地分支(git br -d< branch>),然后再push删除远程分支
Git远程仓库管理
GitHub
git remote -v # 查看远程服务器地址和仓库名称
git remote show origin # 查看远程服务器仓库状态
git remote add origin git@ github:robbin/robbin_site.git # 添加远程仓库地址
git remote set-url origin git@ github.com:robbin/robbin_site.git # 设置远程仓库地址(用于修改远程仓库地址) git remote rm< repository> # 删除远程仓库
创建远程仓库
git clone --bare robbin_site robbin_site.git # 用带版本的项目创建纯版本仓库
scp -r my_project.git git@ git.csdn.net:~ # 将纯仓库上传到服务器上
mkdir robbin_site.git&& cd robbin_site.git&& git --bare init # 在服务器创建纯仓库
git remote add origin git@ github.com:robbin/robbin_site.git # 设置远程仓库地址
git push -u origin master # 客户端首次提交
git push -u origin develop # 首次将本地develop分支提交到远程develop分支,并且track
git remote set-head origin master # 设置远程仓库的HEAD指向master分支
也可以命令设置跟踪远程库和本地库
git branch --set-upstream master origin/master
git branch --set-upstream develop origin/develop
code manager tools git的使用;的更多相关文章
- code manager tools TotoiseSVN安装及使用
TotoiseSVN安装及使用 TotoiseSVN官方下载地址:http://tortoisesvn.net/downloads.html TotoiseSVN安装:很简单,一路直下:就不在这说了, ...
- code manager tools svn服务安装配置
svn server 安装配置: 下载地址:http://www.visualsvn.com/server/download/ 然后安装图一步一步前进: 1.点击download now: 2.点击N ...
- code manager tools myeclipse10 svn插件安装及使用
一.下载: 1.在线安装地址:http://subclipse.tigris.org/update_1.6.x 2.安装包下载地址:http://subclipse.tigris.org/servle ...
- 10 Code Coverage Tools for C & C++
Code coverage is a measure used in software testing that describes the degree to which the source co ...
- .NET CORE 框架ABP的代码生成器(ABP Code Power Tools )使用说明文档
前言 各位好,又是一个多月没更新文章了. 原因嘛,大家都懂的,太忙了~ 临近年末,公司的项目.年会的做技术支持,同事朋友聚餐也比较频繁. 当然视频教程也没有继续更新.我的锅~ 但是这个月好歹抽空做了一 ...
- 从code review到Git commit log
最近在读一本技术类的书:朱赟——<跃迁:从技术到管理的硅谷路径>,其中聊了很多很有趣的观点,比如:技术管理.技术实践.硅谷文化.个人成长等. 读到关于硅谷人如何做code review这一 ...
- 如何在"Visual Studio Code"中使用" Git" 进行版本控制
如何在"Visual Studio Code"中使用" Git" 进行版本控制 本来认为此类教程,肯定是满网飞了.今天首次使用VS Code的Git功能,翻遍了 ...
- Top 40 Static Code Analysis Tools
https://www.softwaretestinghelp.com/tools/top-40-static-code-analysis-tools/ In this article, I have ...
- 下载安装go插件包报错fatal: unable to access 'https://github.com/golang/tools.git/': OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054
使用git命令来给vscode安装go插件的时候报错,如下: $ git clone https://github.com/golang/tools.git tools Cloning into 't ...
随机推荐
- Analyzer使用第二Y轴,以及同一分析图不同量值使用不同的图形样式
Analyzer的建立分析图后,图中有两个量值,希望能显示成不同的图形样式,如一个是柱图.一个是线图. 1.设置显示多个量值: 3.设置显示出图例,即表明图中量值内容的说明: 2.右键图例中要修改为不 ...
- 03.Hibernate一对多关联
前言:在域模型中,类与类之间最普遍的关系就是关联关系,在UML语言中关联关系是有方向的.在数据库中表与表之间也会有关联关系,本节介绍通过Hibernate映射一对多的关联关系,这是一种最普遍的关联关系 ...
- Nodejs Express 4.X 中文API 4--- Router篇
相关阅读: Express 4.X API 翻译[一] -- Application篇 Express4.XApi 翻译[二] -- Request篇 Express4.XApi 翻译[三] -- ...
- spring mvc注解@RequestParam
在spring mvc 的使用过程中 获取 页面传来的参数的时候,我平时都习惯 @RequestParam String name,突然有一天我发现 直接在方法参数后面写 String name , ...
- mybatis中:returned more than one row, where no more than one was expected.异常
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorEx ...
- PHP几个函数
pack: 数据装入一个二进制字符串 http_build_query: 将数组转化成URL GET参数的形式. get_class:返回对象的类名,注:即使是在父类方法中调用也是返回子类的类名. g ...
- 流程控制语句和增强for循环
import java.lang.Math; //import java.util.Arrays; public class test{ public static void main(String[ ...
- IT主要在线学习网站
大的模式来说,目前做编程学习网站的大概有两种.一种是视频模式,如优才,麦可,开课吧等,一种是非视频模式如计蒜客(泡面吧),实验楼和他们汇智网等.其中多数产品的创新也都是在“视频+交互式学习”模式上.要 ...
- iOS-CALayer实现简单进度条
/** * 用CALayer定制下载进度条控件 * 1.单独创建出CALayer * 2.直接修改CALayer的frame值,执行隐式动画,实现进度条效果 * 3.用定时器(NSTimer) ...
- SQL技术内幕-10 in和exists 性能比较
in和exists in 是把外表和内表作hash 连接,而exists是对外表作loop循环,每次loop循环再对内表进行查询. 一直以来认为exists比in效率高的说法是不准确的. 如果查询的两 ...