GIT常用指令

git指令记录

  • 帮助文档
git --help   帮助概要

需要查看某个指令的详细帮助,使用下列类似指令,即可打开本地的git-doc文档
git stash --help   
git branch --help
  • 回退操作
1. git log 找commit id 
2. git reset --hard commitId
3. 不需要git commit -m ''
4. git push --force 强推上去
  • 强拉远端分支到本地
git pull --force  <远程主机名> <远程分支名>:<本地分支名>
git pull --force origin master:master
  • 合并部分commit (cherry-pick)
1 新建临时分支
git checkout -b xxx --track origin/xxx
2 查看想要的branch的commit id
git log -3 --graph test
3 把想要的commit id合入临时分支
git cherry-pick commitId
4 临时分支推送到目标分支,删除临时分支
  • 强推本地到远端某分支
git push origin 远端分支名 --force
  • SSH和HTTP源切换
git remote -v   查看当前所在的本地分支 和其跟踪的远端分支 的通道(就是看是ssh连接还是http连接)

//SSH切换HTTP
git remote set-url origin http://xxx/xxx.git
//HTTP切换SSH:
git remote set-url origin git@git.xxx:xxx/xxx.git  

posted on   博客园里的蜗牛  阅读(17)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· Ollama——大语言模型本地部署的极速利器
· 使用C#创建一个MCP客户端
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· Windows编程----内核对象竟然如此简单?
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示