一些命令
查看本地分支: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"