最近想给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. Spring boot 整合 Mybatis (完整版)

    最近工作上时间有点多,然后自己就学习了一下Spring boot,外加上Mybatis,在实际开发中都是比较常用的,所以这篇写一下SpringBoot整合Mybatis. 一.数据准备 CREATE ...

  2. shell编程-项目部署(优化篇)

    在实际工作中小编遇到了一个问题那就是当我去操作部署脚本的时候,另一个人也可以操作,这怎么能行啊,后来小编就觉得重新优化下代码,给它加一个进程锁 老规矩,先梳理下思路: 同一时间内,脚本只能够允许一个人 ...

  3. ML笔记:Classification: Logistic Regression

  4. mv&cp

    mv [选项] [源] [目标] 当目标不存在时,重命名源为目标 当目标存在时,若目标为目录文件,将源移动到目标文件里: 若目标为非目录文件,将源重命名为目标,并强制覆盖目标.   mv -b 1 2 ...

  5. [Codeforces 946D]Timetable

    Description 题库链接 给你一个 \(N\times M\) 的 \(01\) 矩阵,你可以从中将一些 \(1\) 变为 \(0\) ,最多 \(K\) 次.使操作之后使得每行最远的 \(1 ...

  6. POJ 1721 CARDS

    Alice and Bob have a set of N cards labelled with numbers 1 ... N (so that no two cards have the sam ...

  7. 计蒜客NOIP模拟赛(3)D2T1 小区划分

    一条街道的两侧各连续坐落着 N 座单元楼.现在要为这些单元楼划分居民校区. 规则如下: 每个小区只能由同一侧连续的若干座单元楼组成.且两侧都恰有 K 个小区(每个小区至少有一栋楼). 两侧的小区划分规 ...

  8. 网络编程基础API

    1.预备知识 网络字节序 1.TCP/IP协议规定,网络数据流应采用大端字节序 0x12345678 小端存储:78存储在低地址 大端存储:12存储在低地址 网络字节序和主机字节序的转换 #inclu ...

  9. 2015 多校联赛 ——HDU5344(水)

    Problem Description MZL loves xor very much.Now he gets an array A.The length of A is n.He wants to ...

  10. hdu 5532(最长上升子序列)

    Input The first line contains an integer T indicating the total number of test cases. Each test case ...