首页 > 系统 > Linux >

常用git命令,get最新的abbreviated commit hash

2017-09-25

常用git命令,get最新的abbreviated commit hash。

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
相关文章
最新文章
热点推荐