Git:常用功能 - 命令行
1. 正在某个分支进行开发,突然有个紧急BUG需要切换到其他分支进行修复?
git add README.md # 将文件添加到暂存区 git stash save "v1.0.0 in development" # 贮藏暂存区的修改 # do something in other branch & checkout previous branch git stash list # 显示贮藏列表
# output:"stash@{0}: On master: v1.0.0 in development" git stash pop stash@{} # 应用贮藏的修改
2. 提交了N个版本后发现代码有问题,想重置代码到某个版本?
git log --pretty=format:"%h %an %ar: %s" # 输出日志,格式:提交的简短哈希值 作者 提交时间 提交
# output:"
ac4b4fc YaungOu minutes ago: fix(bug-): fix something
868e045 YaungOu minutes ago: fix(bug-): fix something
aa13e9b YaungOu minutes ago: fix(bug-): fix something
4169d73 YaungOu minutes ago: fix(bug-): fix something
a142e95 YaungOu minutes ago: fix(bug-): fix something
c221ede YaungOu minutes ago: init
" git reset --hard 868e045 # 重置提交历史到该版本,并丢弃所有修改
3. 重置代码到某个版本,不小把有用的提交也重置?
git reflog # 查看所有操作记录(包括reset操作)
# output:"
868e045 HEAD@{}: reset: moving to 868e045
ac4b4fc HEAD@{}: commit: fix(bug-): fix something
868e045 HEAD@{}: commit: fix(bug-): fix something
aa13e9b HEAD@{}: commit: fix(bug-): fix something
4169d73 HEAD@{}: commit: fix(bug-): fix something
a142e95 HEAD@{}: commit: fix(bug-): fix something
c221ede HEAD@{}: commit (initial): init
"
git branch resume-master ac4b4fc # 基于某个版本创建新的分支 # 合并分支或者创建、应用补丁
4. 不小心清空了贮藏的修改(贮藏也要好好写备注喔(●'◡'●),不然想搜索也难)
git fsck --lost-found | awk '{print $3}' | xargs git show | grep -C 5 v1.0.5 # 找回丢失的对象 | 获取对象哈希值 | 显示对象内容 | 根据关键搜索
# output:"
Checking object directories: 100% (256/256), done.
commit 52b018c63226ec7e1f4ddfc349111840dc61c6cc
Merge: a142e95 e9c39a1
Author: YaungOu
Date: Wed May 17 01:22:56 2017 +0800
On master: v1.0.5 in development
commit 635b85f8113df5672c91274d925b4d66d6eae6b7
Author: YaungOu
Date: Tue May 16 22:56:44 2017 +0800
"
git stash apply 52b018c63226ec7e1f4ddfc349111840dc61c6cc # 应用上一个命令得到的HashId对应的修改
未完待续。。。
Git:常用功能 - 命令行的更多相关文章
- git常用的命令行
git管理相关基础命令行,因为现在很多公司都用git管理代码,所以被问及的概率很大,可以用pycharm的git系统,也可以用git代码管理 $git init #初始化仓库$git branch 分 ...
- 十五个最常用Linux命令行 - imsoft.cnblogs
众多Linux管理员在使用Linux的时候会经常使用到很多Linux命令行,其中有绝大部分不是经常使用到的.在本文中主要为大家总结了经常使用的十五个最常用Linux命令行,希望对刚刚接触Linux命令 ...
- 十条常用nmap命令行格式
十条常用nmap命令行格式 ) 获取远程主机的系统类型及开放端口 nmap -sS -P0 -sV -O <target> 这里的 < target > 可以是单一 IP, 或 ...
- git常用的命令你知道有哪些?
1.git与svn的区别 1,git是目前世界上最先进的分布式版本控制系统,他没有中央服务器,每个人的电脑就是一个完整的版本库,这样,工作的时候不需要联网 2,svn是集中式版本控制系统,版本库是集中 ...
- redis常用的命令行以及操作
redis常用的命令行以及操作 转载酱紫人的理直气壮 最后发布于2018-07-30 17:00:41 阅读数 805 收藏 转载地址:https://blog.csdn.net/li_lening ...
- Vim中常用的命令行
Vim中常用的命令行... ------------------- 一些真正强大的武器总不是那么容易驾驭的,主角总得付出一些努力才能收获到更加强大的力量,对于 Vim 这种上古神器来说更是如此.由于它 ...
- Mac 下 Git 的基础命令行操作
Mac 下 Git 的基础命令行操作 sudo apt-get install git-core //安装Git 用户配置 git config --global user.name "Yo ...
- flutter之VSCode下Flutter常用终端命令行
https://www.cnblogs.com/lxlx1798/p/11049922.html 梁飞宇 [Flutter学习]之VSCode下Flutter常用终端命令行 Flutter 常用命令行 ...
- ipmi常用的命令行命令
前言 记录一些常用的命令行操作 命令 查询机器的电源状态 ipmitool -I lanplus -U admin -P admin -H 172.16.21.215 power status 硬重启 ...
随机推荐
- Dubbox中开发REST风格的远程调用
转载: http://zyg345646335.iteye.com/blog/2208899
- echarts仪表盘如何设置图例(legend)
echarts 图表中经常需要对不同的颜色设置图例标识不同的意义,而仪表盘的指针只存在一个值,如何表示不同颜色的意义,官网配置项并未给出该功能: 不同段的颜色是通过axisLine->lineS ...
- EJB基础知识
本人博客文章网址:https://www.peretang.com/basic-knowledge-of-ejb/ 什么是EJB 可移植的, 可重用的, 可伸缩的业务应用程序的平台 为什么选择EJB ...
- 网络接口配置--Bonding
Bonding 就是讲到快网卡绑定到同一IP地址对外服务,可以实现高可用或者负载均衡.当然,直接给两块网卡设置同一IP地址是不可能的.通过bonding,虚拟一块网卡对外提供连接,物理网卡被修改为同一 ...
- Linux下的视频字幕编辑
一.Linux下的字幕编辑软件 常用的有subtitleeditor, gnome-subtitles, gaupol 1.gnome-subtitles:不支持多字幕文件批量处理2.gaupol:全 ...
- js中年份、月份下拉框
<select id="year" style="width: 100px;"></select> <select id=&quo ...
- my97自定义事件
onFocus="WdatePicker({onpicked:function(){alert(0);}})"
- 修改linux的系统时间
可以使用date命令.date用于打印或设置系统日期和时间.设置系统时间需要root权限.用法示例:设置系统日期成2015年08月13日,这样会把具体时间设置清空成00:00:00$ sudo dat ...
- [leetcode-474-Ones and Zeroes]
In the computer world, use restricted resource you have to generate maximum benefit is what we alway ...
- Linux 多用户系统
Linux OS是基于Unix系统开发而来,我们知道计算机是昂贵与稀缺的资源,所以一台计算机就要满足多个用户同时使用,即多用户的系统的思想. 实现方式:通过分时共享的策略.即让多个用户可以同时使用一台 ...