最近想给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 -agit 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的命令的更多相关文章

  1. 廖老师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查看分支情况,确 ...

  2. 关于Git中的一些常用的命令

    深入了解git的checkout命令 检出命令(git checkout)是Git最常用的命令之一,同时也是一个很危险的命令. 因为这条命令会重写工作区.检出命令的用法如下: 用法一: git che ...

  3. Git和Github的应用与命令方法总结

    title: Git和Github的应用与命令方法总结 date: 2016-07-11 14:03:09 tags: git/github [本文摘抄自微信公众平台:AndroidDeveloper ...

  4. git基本命令--tag, alias,

    git tag: 列出标签 在 Git 中列出已有的标签是非常简单直观的. 只需要输入 git tag: $ git tag v0. v1. 这个命令以字母顺序列出标签:但是它们出现的顺序并不重要. ...

  5. 架构(四)Git简介,安装以及相关命令SourceTree

    一 Git介绍 1.1 Git是什么? Git是一个分布式版本控制软件: 版本控制:假如开发人员开发了一个a功能,结果项目经理觉得不够需要修改,开发人员又改成了b功能,后来又改成了c功能,但是最终项目 ...

  6. Git的原理简介和常用命令

    Git和SVN是我们最常用的版本控制系(Version Control System, VCS),当然,除了这二者之外还有许多其他的VCS,例如早期的CVS等.顾名思义,版本控制系统主要就是控制.协调 ...

  7. Git打Tag相关操作

    一.打标签 git tag -a 0.1.3 -m “Release version 0.1.3″ 详解: git tag 是命令 -a 0.1.3是增加 名为0.1.3的标签 -m 后面跟着的是标签 ...

  8. Git-学习笔记(常用命令集合)

    这里引用一下百度百科里Git的内容: Git --- The stupid content tracker, 傻瓜内容跟踪器.Linus Torvalds 是这样给我们介绍 Git 的. Git 是用 ...

  9. Git深入浅出使用教程:Git安装、远程控制、常用命令(全)

    一.软件安装 1.先安装[Git-2.24.1.2-64-bit.exe]软件.(官网下载的很慢,可以在百度云盘下载我的) 链接:https://pan.baidu.com/s/1uoIS9DWSBp ...

随机推荐

  1. Unity中的基础光照

    渲染包含了两大部分:决定一个像素的可见性,决定这个像素上的光照计算. 光照模型就是用于决定在一个像素上进行怎样的光照计算. 一.光源 在实时渲染中我们通常把光源当做一个没有体积的点. 1.1 辐照度 ...

  2. leetcode 448. Find All Numbers Disappeared in an Array -easy (重要)

    题目链接: https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/description/ 题目描述: Give ...

  3. [LeetCode] Longest Line of Consecutive One in Matrix 矩阵中最长的连续1

    Given a 01 matrix M, find the longest line of consecutive one in the matrix. The line could be horiz ...

  4. bootStrap Table 如何使用

    最近在使用bootStrap Table 的表格功能有一些自己的理解写下来分享一下主要用的是一个bootStrapTable 和 jquery 的混合开发 具体怎样引入bootStrap Table ...

  5. ES6(let.contest命令)

    1.作用域概念? 1.全局作用域 2.函数作用域 3.块级作用域(ES6新增) 2.如何使用let和const? 1.代码: 运行结果为1.将let改为var,发现结果不变. 代码: 发现报错!!!( ...

  6. 【实验吧】CTF_Web_因缺思汀的绕过

    打开页面,查看源代码,发现存在source.txt(http://ctf5.shiyanbar.com/web/pcat/source.txt),如下: <?php error_reportin ...

  7. [WC 2005]友好的生物

    Description $W$ 星球是一个和地球一样气候适宜.物种聚集的星球.经过多年的研究,外星生物学家们已经发现了数万种生物,而且这个数字还在不断增大. $W$ 星球上的生物很有趣,有些生物之间很 ...

  8. C++Primer学习——const

    Const int size = 512; 在编译的时候,编译器会把用到该变量的地方全部替换成对应的值. const&可以绑定字面值,所以当用常量引用绑定一个常量时,是否可以看成那个值在编译阶 ...

  9. javascript 手势(swipeLeft,swipeRight)滑动中使用css3动画卡顿,开启硬件加速

    今天,在做一个移动端项目,遇到了css3动画卡顿的现象. 例图: 在手势滑动中(swipeLeft,swipeRight)遇到了动画卡顿的现象,最后使用了css3动画-webkit-transform ...

  10. 如何查看cisco 生成树状态

    如何查看cisco 生成树状态  Role(角色): 1.Desg(指定端口)   2.Root(根端口)    3.Altn(替换端口) Sts(状态): 1.FWD(转发)      2.BLK( ...