git相关命令

一些命令

查看本地分支:git branch --list git branch -a

切换分支:git checkout branch-name

重命名本地分支/远程分支

重命名本地分支

重命名当前分支

复制代码
git branch -m new-name

重命名其他分支

复制代码
git branch -m old-name new-name

ps:重命名后可以使用git branch --list git branch -a检查分支名是否成功修改。

重命名远程分支

只能删除旧远程分支,上传新分支

1.删除旧远程分支:git push origin --delete old-branch-name

2.重置上游分支名为新本地分支的名称:git push origin -u new-branch-name

3.登录远程仓库确认分支名已修改

stash相关

查看临时保存列表

复制代码
$ git stash list

删除临时保存的变更点

删除最新暂存

复制代码
$ git stash drop

删除指定暂存

复制代码
$ git stash dorp stash@{stash序号}

例如:

复制代码
$ git stash drop stash@{1}

清空stash

复制代码
$ git stash clear

修改最后一次提交 commit 的信息

  • 修改最近提交的 commit 信息

    $ git commit --amend --message="message text" --author="xxx xx@xxx.com"

  • 仅修改 message 信息

    $ git commit --amend --message="message text"

  • 仅修改 author 信息

    $ git commit --amend --author="xxx xx@xxx.com"

相关推荐
xlq223224 小时前
2.git
git
OYangxf4 小时前
Git Ignore
大数据·git·elasticsearch
哆哆啦005 小时前
obsidian远程同步方案:infiniCloud+remotely save方案
笔记·git·obsidian
西柚小萌新6 小时前
【计算机常识】--使用 Gitea 在本地/内网搭建 Git 私有服务器
服务器·git·gitea
zhangfeng11337 小时前
scp 命令的使用方法 什么软件支持 .git bash xshell .openssh
开发语言·git·bash
_君莫笑15 小时前
大厂Git使用规范
git
无心水1 天前
【Hermes:安全、权限与生产环境】39、智能体也会犯错?Hermes 纠错、回滚与遗忘机制全指南 —— 让 AI 的错误像 Git 一样可逆可控
人工智能·git·安全·mcp协议·openclaw·hermes·honcho
南境十里·墨染春水1 天前
linux学习进展 git详解
linux·git·学习
zhangfeng11331 天前
CodeBuddy ai对话框上面的git docs terminal Rulds 干嘛用的,以thinkphp fastadmin 为例,插件市场
人工智能·git·编程