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 ...
随机推荐
- Java图形界面学习---------简易登录界面
/** * @author Administrator * Java图形界面学习---------简易登录界面 * date:2015/10/31 */ import java.awt.BorderL ...
- python 虚拟环境的搭建
1.python3.6 2.MySQL 3.安装虚拟环境 1.pip install virtualenv -i https://pypi.douban.com/simple/ 2.pip ins ...
- 机器学习技法:13 Deep Learning
Roadmap Deep Neural Network Autoencoder Denoising Autoencoder Principal Component Analysis Summary
- [CQOI2013]新Nim游戏
Description 传统的Nim游戏是这样的:有一些火柴堆,每堆都有若干根火柴(不同堆的火柴数量可以不同).两个游戏者轮流操作,每次可以选一个火柴堆拿走若干根火柴.可以只拿一根,也可以拿走整堆火柴 ...
- LOJ #6041. 事情的相似度
Description 人的一生不仅要靠自我奋斗,还要考虑到历史的行程. 历史的行程可以抽象成一个 01 串,作为一个年纪比较大的人,你希望从历史的行程中获得一些姿势. 你发现在历史的不同时刻,不断的 ...
- Topcoder口胡记 SRM 562 Div 1 ~ SRM 599 Div 1
据说做TC题有助于提高知识水平? :) 传送门:https://284914869.github.io/AEoj/index.html 转载请注明链接:http://www.cnblogs.com/B ...
- hdu 2296 aC自动机+dp(得到价值最大的字符串)
Ring Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- Bubble Cup X - Finals [Online Mirror]
来自FallDream的博客,未经允许,请勿转载,谢谢. 组了个菜鸡队打cf上的ACM比赛 比较快做完了8题但是菜的抠脚罚时巨多,所以最后被顶到了19名(居然没出首页) 自己的号自从上次疯狂掉分就没动 ...
- 2393Cirno的完美算数教室 容斥
2393: Cirno的完美算数教室 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 652 Solved: 389[Submit][Status][ ...
- NTT+多项式求逆+多项式开方(BZOJ3625)
定义多项式$h(x)$的每一项系数$h_i$,为i在c[1]~c[n]中的出现次数. 定义多项式$f(x)$的每一项系数$f_i$,为权值为i的方案数. 通过简单的分析我们可以发现:$f(x)=\fr ...