• 正文
    • 切換遠(yuǎn)程地址
    • 推送到指定地址分支
    • git 版本回退
  • 相關(guān)推薦
申請(qǐng)入駐 產(chǎn)業(yè)圖譜

git 切換遠(yuǎn)程地址分支 推送到指定地址分支 版本回退

02/06 13:31
355
加入交流群
掃碼加入
獲取工程師必備禮包
參與熱點(diǎn)資訊討論

切換遠(yuǎn)程地址

1、切換遠(yuǎn)程倉庫地址:

方式一:修改遠(yuǎn)程倉庫地址

【git remote set-url origin URL】 更換遠(yuǎn)程倉庫地址,URL為新地址。

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

方式二:先刪除遠(yuǎn)程倉庫地址,然后再添加

【git remote rm origin】 刪除現(xiàn)有遠(yuǎn)程倉庫

【git remote add origin url】添加新遠(yuǎn)程倉庫

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 】查看遠(yuǎn)程倉庫的地址

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、查看本地址和遠(yuǎn)程版本

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代表遠(yuǎn)程分支

git push <遠(yuǎn)程主機(jī)名> <本地分支名>:<遠(yuǎn)程分支名>

例:

git push omj_gateway develop:develop --force

git 版本回退

查看歷史版本

1、查看歷史版本 詳細(xì)提交歷史 (q退出)

git logq退出

2、 最近提交版本簡(jiǎn)要

git reflog

回退本地版本

1、回退到上一個(gè)版本

git reset --hard HEAD^

2、回退某個(gè)版本

git reset --hard 530ae79

遠(yuǎn)程服務(wù)器回退版本

1、先回退本地git版本

2、查看git分支

git branch -v -a

3、推送到遠(yuǎn)程git

git push origin HEAD --force

相關(guān)推薦

登錄即可解鎖
  • 海量技術(shù)文章
  • 設(shè)計(jì)資源下載
  • 產(chǎn)業(yè)鏈客戶資源
  • 寫文章/發(fā)需求
立即登錄