git常用命令

优雅地进行强制推送

git push --force-with-lease

这个强制推送,仅在服务器没有新的commit的时候执行成功

 

删除远程分支

https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-both-locally-and-remotely?page=1&tab=votes#tab-top

git push -d remotename branchname

 

 

在不切换分支的情况下,重置一个分支指向的commit

https://stackoverflow.com/questions/5471174/move-branch-pointer-to-different-commit-without-checkout

git branch -f branch-name new-tip-commit

 

重命名分支

https://stackoverflow.com/questions/6591213/how-do-i-rename-a-local-git-branch

If you want to rename a branch while pointed to any branch, do:

git branch -m <oldname> <newname>

If you want to rename the current branch, you can do:

git branch -m <newname>

A way to remember this, is -m is for "move" (or mv), which is how you rename files.

 

显示日志

Many of the answers here are great, but for those that just wants a simple one line to the point answer without having to setup aliases or anything extra, here it is:

git log --all --decorate --oneline --graph

Not everyone would be doing a git log all the time, but when you need it just remember: " A Dog " = git log --all --decorate --oneline --graph

 

 

 

posted @ 2018-04-25 10:15  ChuckLu  阅读(190)  评论(0编辑  收藏  举报