Git Code Snippets - WBowam/wbowam.github.com GitHub Wiki

Date: 2015-05-11
Title: Git 命令碎片
Tags: Snippets, Git
Category: IT

MAKE GIT PUSH AND PULL TO THE CURRENT BRANCH BY DEFAULT

git config --global push.default current
git config --global pull.default current

git tag

$ git tag -a v1.4 -m 'my version 1.4'
$ git tag
v0.1
v1.3
v1.4

$ git show v1.4
tag v1.4
Tagger: Ben Straub <[email protected]>
Date:   Sat May 3 20:19:12 2014 -0700

my version 1.4

commit ca82a6dff817ec66f44342007202690a93763949
Author: Scott Chacon <[email protected]>
Date:   Mon Mar 17 21:52:11 2008 -0700

    changed the version number

$ git push origin v1.5
$ git checkout -b version2 v2.0.0
Switched to a new branch 'version2'

show details of git commit

git log -p
# 或
git log -p commit1 commit2

delete remote/local branch

$ git push origin --delete <branchName>
删除tag这么用:

git push origin --delete tag <tagname>

否则,可以使用这种语法,推送一个空分支到远程分支,其实就相当于删除远程分支:

git push origin :<branchName>
这是删除tag的方法,推送一个空tag到远程tag:

git tag -d <tagname>
git push origin :refs/tags/<tagname>

clear useless docker images

sudo docker rm $(sudo docker ps -aq)
sudo docker rmi $(sudo docker images -aq)
#或
docker images --no-trunc| grep none | awk '{print $3}' | xargs -r docker rmi
docker ps -a| grep Exit | awk '{print $1}' | xargs -r docker rm

git commit --amend

一次性提交

⚠️ **GitHub.com Fallback** ⚠️