1. 获取当前分支
     git symbolic-ref -q --short HEAD

2. 在git别名里使用shell函数,$1获取第一个参数的值,$2……$n依次类推,根据自己习惯需要定制

3. 提交review的正确语句是: git push origin HEAD:refs/for/destination_branch 意思是---把当前分支的代码推送到远程origin仓库的review分支destination_branch上去

origin表示远程git服务器地址;HEAD表示当前分支;refs/for/destination_branch 表示远程review分支

4. 下面配置的含义:

  • 执行git review等价于git push origin HEAD:refs/for/current_branch
  • 执行git review destination_branch等价于git push origin HEAD:refs/for/destination_branch
review = "!f() { if [ -z $1 ];then currBra=`git symbolic-ref -q --short HEAD`;else currBra=$1;fi;git push origin HEAD:refs/for/$currBra; }; f"

全部配置:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = ssh://san.zhang@gerrit.xxx.me:29418/ganhui.zhang/gerrit_test
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[branch "gerrit_test1811052223a"]
    remote = origin
    merge = refs/heads/gerrit_test1811052223
[branch "gerrit_test1811052223"]
    remote = origin
    merge = refs/heads/gerrit_test1811052223
[alias]
    st = status
    review = "!f() { if [ -z $1 ];then currBra=`git symbolic-ref -q --short HEAD`;else currBra=$1;fi;git push origin HEAD:refs/for/$currBra; }; f"

配置生效的地方,优先级由高到底:

  • 项目配置,位于项目下的.git/config   查看git config --local  --list编辑git config --local  -e
  • 某个用户下的所有项目配置:~/.gitconfig   查看git config --global --list编辑git config --global  -e
  • 当前系统下的所有用户所有项目配置:/etc/gitconfig  查看git config --system --list编辑git config --system  -e

注意:

配置的时候请使用命令:git config --local/--global/--system -e方式;

不要使用 git config --local/--global/--system alias.review "!f() { if [ -z $1 ];then currBra=`git symbolic-ref -q --short HEAD`;else currBra=$1;fi;git push origin HEAD:refs/for/$currBra; }; f"

https://hellomin.github.io/2018/09/11/%E5%8F%AF%E9%85%8D%E7%BD%AE%E5%8F%82%E6%95%B0%E7%9A%84Git%E5%88%AB%E5%90%8D/

git别名;git配置使用shell函数;git别名使用shell函数;git获取当前分支;git alias的更多相关文章

  1. Git 基础 —— 安装 配置 别名 对象

    Git 基础学习系列 Git 基础 -- 安装 配置 别名 对象 Git 基础 -- 常用命令 Git 基础 -- 常见使用场景 Git基础 -- Github 的使用 Git 安装 Git下载地址 ...

  2. Mac上git的安装配置与使用简述

    Mac下git搭建及使用 之前就只是经常在GitHubs上下载代码,也没注意怎么上传项目.一开始对git都没什么了解花了几个小时去小补了下知识.如果有需要可以转去这里学习:[GIT使用简易指南] (h ...

  3. Git多账号配置,同一电脑多个ssh-key的管理

    为什么有这种需求? 在我们开发过程中,可能会遇到使用同一台机器,既要向公司git服务器提交代码,也要向gitlib或者gitee等 git仓库提交代码,2个仓库设置的用户名信息,不一样,此时需要用到多 ...

  4. git之win安装git和环境配置及常用命令总结

    12.windowns安装git和环境变量配置 11.git之常见命令总结 ===== 12.windowns安装git和环境变量配置 ; 转自 https://wuzhuti.cn/2385.htm ...

  5. Windows下Git多账号配置,同一电脑多个ssh-key的管理

    这一篇文章是对上一篇文章<Git-TortoiseGit完整配置流程>的拓展,所以需要对上一篇文章有所了解,当然直接往下看也可以,其中也有一些提到一些基础的操作. <Git-Tort ...

  6. Win7上Git安装及配置过程

    Win7上Git安装及配置过程 文档名称 Win7上Git安装及配置过程 创建时间 2012/8/20 修改时间 2012/8/20 创建人 Baifx 简介(收获) 1.在win7上安装msysgi ...

  7. Windows系统中Git的安装配置

    一.Git安装 1.下载 Git官网:https://git-scm.com/download/ 选择windows版本下载即可. 百度软件中心:http://rj.baidu.com/ 如官网下载不 ...

  8. Ubuntu12.04 Git 服务器详细配置

    Git是一款免费.开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目,学过Linux的都知道,Git的优点我就不再多说了,我也是很喜欢Linux的.今天我们一起学习Git服务器在Ubunt ...

  9. g4e基础篇#3 Git安装与配置

    g4e 是 Git for Enterprise Developer的简写,这个系列文章会统一使用g4e作为标识,便于大家查看和搜索. 章节目录 前言 1. 基础篇: 为什么要使用版本控制系统 Git ...

随机推荐

  1. ubuntu下hadoop,spark配置

    转载来自:http://www.cnblogs.com/spark-china/p/3941878.html 在VMWare 中准备第二.第三台运行Ubuntu系统的机器:   在VMWare中构建第 ...

  2. linux学习笔记-5.用户和组

    1.添加一个tom用户,设置它属于users组,并添加注释信息 分步完成: useradd tom usermod -g users tom usermod -c "hr tom" ...

  3. httpclient初步封装

    Http通信方式:HttpURLConnection和HttpClient HttpURLConnection是java的标准类,什么都没封装,用起来太原始,不方便HttpClient就是一个增强版的 ...

  4. html (第四本书第六章盒子模型参考)

    上机1 <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8 ...

  5. DPDK+OpenvSwitch-centos7.4安装

    系统版本 [root@controller ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) DPDK版本: dpdk- ...

  6. 模板 图的遍历 bfs+dfs 图的最短路径 Floyed+Dijkstra

    广搜 bfs //bfs #include<iostream> #include<cstdio> using namespace std; ],top=,end=; ][]; ...

  7. BZOJ.3624.[APIO2008]免费道路(Kruskal)

    题目链接 我们发现有些白边是必须加的,有些是多余的. 那么我们先把所有黑边加进去,然后把必须要加的白边找出来. 然后Kruskal,把必须要加的白边先加进去,小于K的话再加能加的白边.然后加黑边. 要 ...

  8. curl请求指定host ip(指定域名解析的内网某ip)

    域名www.test.com解析内部多台ip $httpHeader = array('Host: www.test.com');$url = "10.17.2.245/xxx/xxx/t. ...

  9. 最短路径:(Dijkstra & Floyd)

    Dijkstra算法 1.定义概览 Dijkstra(迪杰斯特拉)算法是典型的单源最短路径算法,用于计算一个节点到其他所有节点的最短路径.主要特点是以起始点为中心向外层层扩展,直到扩展到终点为止.Di ...

  10. 【BZOJ-2142】礼物 拓展Lucas定理

    2142: 礼物 Time Limit: 10 Sec  Memory Limit: 259 MBSubmit: 1313  Solved: 541[Submit][Status][Discuss] ...