最近想给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. VC2013 代码图,依赖项关系图,等出错解决办法.

    环境WIN10+VS2013+SQL2015 当VS2013代码图,依赖项关系图等出现 数据库连接错误时 去http://www.microsoft.com/zh-cn/download/detail ...

  2. MongoDB 分片集群搭建

    一.概述 分片是一种在多台机器上分配数据的方法.MongoDB使用分片来支持具有非常大的数据集和高吞吐量操作.有两种解决系统增长的方法:垂直扩展和水平扩展. 垂直扩展涉及增加单个服务器的容量,例如使用 ...

  3. springboot快速入门

    SpringBoot简介 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人员不再 ...

  4. leetcode 283. Move Zeroes -easy

    题目链接:https://leetcode.com/problems/move-zeroes/ 题目内容: Given an array nums, write a function to move ...

  5. springboot+shiro+redis项目整合

    介绍: Apache Shiro是一个强大且易用的Java安全框架,执行身份验证.授权.密码学和会话管理.使用Shiro的易于理解的API,您可以快速.轻松地获得任何应用程序,从最小的移动应用程序到最 ...

  6. [AtCoder arc090F]Number of Digits

    Description 题库链接 记 \(d\) 在十进制下的位数为 \(f(d)\) .给出询问 \(S\) ,求有多少对 \((l,r)\) 使得 \[\sum_{i=l}^r f(i)=S\] ...

  7. [HNOI2003]消防局的设立

    题目描述 2020年,人类在火星上建立了一个庞大的基地群,总共有n个基地.起初为了节约材料,人类只修建了n-1条道路来连接这些基地,并且每两个基地都能够通过道路到达,所以所有的基地形成了一个巨大的树状 ...

  8. bzoj 2437: [Noi2011]兔兔与蛋蛋

    Description Solution 考虑犯错误的条件:之前是处于必胜状态,该操作之后就变成了必败状态. 我们可以把这个过程看成两人对网格图进行黑白染色,变成了一个二分图模型,即当前位置向相邻不同 ...

  9. 洛谷P1397 [NOI2013]矩阵游戏

    矩阵快速幂+费马小定理 矩阵也是可以跑费马小定理的,但是要注意这个: (图是盗来的QAQ) 就是说如果矩阵a[i][i]都是相等的,那么就是mod p 而不是mod p-1了 #include< ...

  10. 【BZOJ4196】【Noi2015】软件包管理器

    原题传送门 题意: 给你一棵树,有2种操作: 1.使得某个点到根节点路径上的所有点权值赋为1. 2.使得某节点的子树中所有节点权值赋为0. 每次操作要求输出权值更改的节点个数. 解题思路: 显然是用树 ...