常用git命令

get最新的abbreviated commit hash

git rev-parse --short HEAD  
git log -1 --pretty=format:"%h"

add/delete/list tags

  • List tags
git tag  
git tag -l "v0.1*"
  • Add a tag to current HEAD
git tag -a v0.2.0 -m "Release 0.2.0"  
  • Adding a tag to a specific commit with commit_id=a34b6e
git tag -a v0.2.0 a34b6e -m "Release 0.2.0"  
  • Show the tag data
git show v0.2.0  
  • Push all tags
git push --tags  
  • Push a specific tag
git push origin v0.2.0  
  • Delete a local tag
git tag -d v0.1.0  
  • Remove a remote tag
git push origin :refs/tags/v0.1.0  

查看当前branch是从哪个tag创建的

git describe --tags

Error when switch branch

error: The following untracked working tree files would be overwritten by checkout
Please move or remove them before you switch branches.
Aborting

Solution:

git clean  -d  -fx ""

Show branch name on the linux prompt

parse_git_branch() {
git branch 2> /dev/null | sed -e ‘/^[^*]/d’ -e ‘s/* \(.*\)/(\1)/’
}
PS1=’${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ ‘
unset color_prompt force_color_prompt
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值