• 正文
  • 相关推荐
申请入驻 产业图谱

git 切换远程地址分支 推送到指定地址分支 版本回退

02/06 13:31
323
加入交流群
扫码加入
获取工程师必备礼包
参与热点资讯讨论

切换远程地址

1、切换远程仓库地址:

方式一:修改远程仓库地址

【git remote set-url origin URL】 更换远程仓库地址,URL为新地址。

git remote set-url https://gitee.com/xxss/omj_gateway.git

方式二:先删除远程仓库地址,然后再添加

【git remote rm origin】 删除现有远程仓库

【git remote add origin url】添加新远程仓库

git remote rm origin https://github.com/****/omj_gateway.git

git remote add origin https://gitee.com/xxss/omj_gateway.gi

2、【git remote -v 】查看远程仓库的地址

omj_gateway https://github.com/****/omj_gateway.git (fetch)

omj_gateway https://github.com/xxs/omj_gateway.git (push)

origin https://gitee.com/xxss/omj_gateway.git (fetch)

origin https://gitee.com/xxs/omj_gateway.git (push)

推送到指定地址分支

1、查看本地址和远程版本

git branch -a
debug

* develop

main

remotes/omj_gateway/develop

remotes/omj_gateway/main

remotes/origin/HEAD -> origin/main

remotes/origin/develop

remotes/origin/main

remotes代表远程分支

git push <远程主机名> <本地分支名>:<远程分支名>

例:

git push omj_gateway develop:develop --force

git 版本回退

查看历史版本

1、查看历史版本 详细提交历史 (q退出)

git logq退出

2、 最近提交版本简要

git reflog

回退本地版本

1、回退到上一个版本

git reset --hard HEAD^

2、回退某个版本

git reset --hard 530ae79

远程服务器回退版本

1、先回退本地git版本

2、查看git分支

git branch -v -a

3、推送到远程git

git push origin HEAD --force

相关推荐