============================================================
博文原创,转载请声明出处
电子咖啡(原id蓝岩)
============================================================
***********git 撤销commit
刚才提交,commit后发现漏了两个文件需要撤销commit,找到方法如下:
$ git commit ... (1)//我刚才的操作
$ git reset --soft HEAD^ (2)//这里就是HEAD^无需改动
$ edit (3)//不需要
$ git add .... (4)//已经撤销,重新你的操作
$ git commit -c ORIG_HEAD (5)
***********修改commit
git commit --amend -m "New commit message"
或者
$ git reset --soft HEAD^
$ ... do something else to come up with the right tree ...
$ git commit -c ORIG_HEAD
***********对比不同版本
git diff 40ef25ddfcee58e610cd06e3923fbc65c044e8c8..HEAD
HEAD表示当前版本,^表示上一个,对比上一个版本和上上个版本,可以
HEAD 是最近一个commit 的内容
$ git diff HEAD^^ HEAD main.c
$ git diff HEAD^^..HEAD -- main.c
**********************
checkou之前的版本是
git checkout 43b23k4h324bq34o4i
checkout 出来的是匿名分支,重命名该匿名分支为
git checkout -b newbranchname
***************
#diff file has added
$ git diff --cached
***********
checkout a tag as branch
git checkout -b appstore v3.0.0_1
***********
删除本地分支
git branch -d the_local_branch
***********
TAG 篇
//show tag info
git show v1.0.0
//show all tags
git tag
//add tag
git tag -a v1.0.0 -m "Creating the first official version."
***********
//revert 某个 commit
git revert dd61ab32
***********
//push a branch
git push -u origin mybranch
***********
***********
***********
***********
***********
***********
***********
***********
***********
***********
***********
***********
***********
***********
***********
***********
***********
***********
***********
***********
***********
***********
***********