git常用命令
优雅地进行强制推送
git push --force-with-lease
这个强制推送,仅在服务器没有新的commit的时候执行成功
删除远程分支
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 |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.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内置的命令行协议的解析