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"

相关推荐
JakeJiang3 小时前
Git 必备命令指南:从日常高频到项目开发实战
git
叫我少年1 天前
Windows 中安装 git
git
深海鱼在掘金6 天前
Git 完全指南 —— 第1章:Git 概览与版本控制演进
git
noravinsc7 天前
关于Git Flow
git
蜜獾云7 天前
在Git中配置用户名和密码
git
scx_link7 天前
通过git bash在本地创建分支,并推送到远程仓库中
开发语言·git·bash
南大白7 天前
IntelliJ IDEA 运行时的 JVM 本地内存溢出崩溃
git
码农小旋风7 天前
Claude Code 基础用法大全:对话、分析、修改、测试、Git 和工作流
人工智能·git·chatgpt·claude
南大白7 天前
Git 撤回提交完整方案
git
像风一样的男人@7 天前
python --实现代理服务器
git·ui