Git 处理tag和branch的命令
最近想给GitHub 上的项目设置tag,可是使用GitHub Desktop,找了一圈都没找到快速设置Tag 的地方,最后只能通过终端命令来添加了。
想要查看Git 的命令,可以使用
git --help
可是大致看一下git的命令:
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status
grow, mark and tweak your common history
branch List, create, or delete branches
checkout Switch branches or restore working tree files
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
merge Join two or more development histories together
rebase Forward-port local commits to the updated upstream head
tag Create, list, delete or verify a tag object signed with GPG
collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
然后使用 git help -a 和 git help -g 可以查看git 的一些子命令和一些概念性的东西。
使用 git help <command> 和 git help <concept> 可以查看某个命令的参数 和描述等详细信息。
要对某个Git 工程做处理,我们首先要先进入该工程的根目录。
可以使用 cd 工程路径 来进入某个工程目录。
然后可以使用 ls -a 或者 ls -al 查看工程目录下是否有隐藏的 .git 文件。
例如我的操作:
bogon:HLBluetoothDemo harvey$ ls -al
total 32
drwxr-xr-x 7 harvey staff 238 11 18 17:41 .
drwxr-xr-x 63 harvey staff 2142 11 1 11:03 ..
-rw-r--r--@ 1 harvey staff 6148 9 28 15:53 .DS_Store
drwxr-xr-x 16 harvey staff 544 11 18 17:41 .git
drwxr-xr-x 23 harvey staff 782 11 18 17:41 HLBluetoothDemo
drwxr-xr-x 5 harvey staff 170 11 18 17:41 HLBluetoothDemo.xcodeproj
-rw-r--r-- 1 harvey staff 5066 11 18 17:41 README.md
Commit 操作
//查看所有提交记录
git log
// 查看简写的提交记录
git log --oneline
Tag 操作
我们可以对某一个稳定的版本设置一个Tag,这样在以后回头来看,也更方便和直接。
查看Tag 命令
// 查看本地的所有Tag
git tag
// 查看某一系列tag
git tag -l v1.*
创建Tag 命令
git tag -a v1.0 -m "对Tag的描述信息"
我们也可以对以前的某次commit 设置tag。
具体的做法是,首先执行 git log --oneline ,找到这次提交的唯一id。
例如:
bogon:HLBluetoothDemo harvey$ git log --oneline
2b04b38 利用iOS 9后的系统API获取特性可写入的最大长度来分割发送。
1468bbe Update README.md
fba0db7 断开连接时,将connectedperpwheral 置为nil
ee76062 Update README.md
576e179 Update README.md
上面的 描述信息前的值,就是id。
然后执行 git tag -a v1.1 2b04b38 -m "Tag的描述信息"
我们可以在本地添加多个tag 后,执行以下 git tag 查看一下本地的tag。
提交本地的Tag 到远程服务器的命令
git push origin --tags
然后,我们就可以去github 上看自己的工程里的tags 了。
删除本地的tag 命令
git tag -d v1.0
上面这个命令只能删除本地的tag,如果这个tag 已经提交到远程服务器之后,上面的命令并不能删除远程服务器上的tag。
要删除远程服务器上的tag,可以使用如下的命令:
git push origin --delete tag v1.0
branch 操作
查看branch 的命令
git branch -a
在终端里,远程的branch会显示为红色,如下图所示:
删除远程branch 的命令
git push origin --delete <branchName>
目前branch 就用到这么多,更详细的,使用git help branch 查看吧。
以后再补充了。
Git 处理tag和branch的命令的更多相关文章
- 廖老师git教程执行"git checkout -b dev origin/dev"命令报出:fatal: Cannot update paths and switch to branch 'dev' at the same time. Did you intend to checkout 'origin/dev' which can not be resolved as commit?问题解决
在学习廖老师git教程之多人协作模块时按照老师的操作先创建了另一个目录,然后在这个目录下从GitHub上clone了 learngit目录到这个目录下,同样的执行了git branch查看分支情况,确 ...
- 关于Git中的一些常用的命令
深入了解git的checkout命令 检出命令(git checkout)是Git最常用的命令之一,同时也是一个很危险的命令. 因为这条命令会重写工作区.检出命令的用法如下: 用法一: git che ...
- Git和Github的应用与命令方法总结
title: Git和Github的应用与命令方法总结 date: 2016-07-11 14:03:09 tags: git/github [本文摘抄自微信公众平台:AndroidDeveloper ...
- git基本命令--tag, alias,
git tag: 列出标签 在 Git 中列出已有的标签是非常简单直观的. 只需要输入 git tag: $ git tag v0. v1. 这个命令以字母顺序列出标签:但是它们出现的顺序并不重要. ...
- 架构(四)Git简介,安装以及相关命令SourceTree
一 Git介绍 1.1 Git是什么? Git是一个分布式版本控制软件: 版本控制:假如开发人员开发了一个a功能,结果项目经理觉得不够需要修改,开发人员又改成了b功能,后来又改成了c功能,但是最终项目 ...
- Git的原理简介和常用命令
Git和SVN是我们最常用的版本控制系(Version Control System, VCS),当然,除了这二者之外还有许多其他的VCS,例如早期的CVS等.顾名思义,版本控制系统主要就是控制.协调 ...
- Git打Tag相关操作
一.打标签 git tag -a 0.1.3 -m “Release version 0.1.3″ 详解: git tag 是命令 -a 0.1.3是增加 名为0.1.3的标签 -m 后面跟着的是标签 ...
- Git-学习笔记(常用命令集合)
这里引用一下百度百科里Git的内容: Git --- The stupid content tracker, 傻瓜内容跟踪器.Linus Torvalds 是这样给我们介绍 Git 的. Git 是用 ...
- Git深入浅出使用教程:Git安装、远程控制、常用命令(全)
一.软件安装 1.先安装[Git-2.24.1.2-64-bit.exe]软件.(官网下载的很慢,可以在百度云盘下载我的) 链接:https://pan.baidu.com/s/1uoIS9DWSBp ...
随机推荐
- MySQL获取XML格式数据
通过再调用mysql工具时使用--xml选项: C:\Users\wang>mysql -uroot -p --xml mydb Enter password: ******** Welcome ...
- Windows安装SVN服务器和客户端
我的操作系统版本是windows10 64位.接下来我会先介绍SVN服务器的安装,然后再介绍安装SVN客户端,并进行测试. 下载 首先我们需要到官网上去下载svn服务器程序. [svn官网地址] (h ...
- C++程序设计语言(特别版) -- 一个桌面计算器
前言 这里要介绍各种语句和表达式,将通过一个桌面计算器的程序做些事情,该计算器提供四种座位浮点数的中缀运算符的标准算术运算. 这个计算器由四个部分组成:一个分析器,一个输入函数,一个符号表和一个驱动程 ...
- .Net Core 学习之路-基础
.Net Core出来好久了,一直在了解,但始终没有应用到实际项目中.... 准备用.net core搞个SSO,才发现它和.net framework的变化并不是一点点... .net core还在 ...
- JavaScript数据结构与算法(一) 栈的实现
TypeScript版本源码 class Stack { items = []; public push(element) { this.items.push(element); } public p ...
- 机器学习技法:12 Neural Network
Roadmap Motivation Neural Network Hypothesis Neural Network Learning Optimization and Regularization ...
- bzoj 4830: [Hnoi2017]抛硬币
Description 小A和小B是一对好朋友,他们经常一起愉快的玩耍.最近小B沉迷于**师手游,天天刷本,根本无心搞学习.但是 已经入坑了几个月,却一次都没有抽到SSR,让他非常怀疑人生.勤勉的小A ...
- [BZOJ]1069 最大土地面积(SCOI2007)
计算几何经典题,贴板子. Description 在某块平面土地上有N个点,你可以选择其中的任意四个点,将这片土地围起来,当然,你希望这四个点围成的多边形面积最大. Input 第1行一个正整数N,接 ...
- scrapy常用命令(持续) | Commonly used Scrapy command list (con't)
以下命令都是在CMD中运行,首先把路径定位到项目文件夹 ------------------------------------------------------------------------ ...
- VS2012代码对齐快捷键
1.选中想要对齐的代码 2.全选代码后按住Ctrl+K,Ctrl+F键,就可以了