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"

相关推荐
慧都小项14 小时前
MyEclipse Inline Diff 实用指南:逐处核对 AI 修改再提交
git·ai编程·myeclipse·java 代码审查·ai 代码修改
德育处主任16 小时前
让 Claude Code 在你睡觉时接着干活:tmux、权限策略与验收清单
git·ai编程·命令行
为思念酝酿的痛3 天前
Git基本操作
git·github
wno7044 天前
常用的Git命令清单
大数据·git·elasticsearch
真上帝的左手4 天前
3. 代码管理-Git-进阶
git·源代码管理
YIN_尹5 天前
【git原理与使用】git基本操作及底层原理(二)
大数据·git·elasticsearch
程序员爱德华5 天前
Git 命令
git
Cry丶5 天前
Git Rebase 操作备忘
git·rebase
你叶不叶6 天前
abap git 如何从 gitee上在线拉取数据(上一步已经配置好证书)
git·gitee·sap·abapgit
kuroomi7 天前
Git入门
git·kubernetes