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

 

 

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(192)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2016-04-25 Array.Copy vs Buffer.BlockCopy
2016-04-25 SuperSocket内置的命令行协议的解析
点击右上角即可分享
微信分享提示