查看
git remote -v
修改
git remote set-url origin http://10.73.171.134:11080/root/zcsnzckg.git
添加
git remote add origin http://10.73.171.134:11080/root/zcsnzckg.git
| 场景 | 命令 | 说明 |
|---|---|---|
| 列出本地分支 | git branch |
当前分支前有 * 标记 |
| 列出远程分支 | git branch -r |
显示 origin/分支名 格式 |
| 列出所有分支 | git branch -a |
本地分支 + 远程分支 |
| 查看分支详细关联 | git branch -vv |
显示本地分支与远程跟踪分支的关联 |
| 查看分支提交历史 | git log <分支名> |
支持查看本地或远程分支 |
| 同步远程分支并清理本地 | git fetch --prune |
更新远程分支信息并删除过时本地分支 |
| 切换本地分支 | git checkout main |
切换当前分支 |
格式:git remote set-url <远程仓库别名> <新的地址>
示例:将 origin 的地址改为 SSH 方式
git remote set-url origin git@github.com:new-user/new-repo.git
git remote set-url origin https://github.com/new-user/new-repo.git
cd existing_repo
git remote add origin http://192.168.40.50/root/zcsnzckg.git
git branch -M main
git push -uf origin main
创建本地标签
轻量标签(简单指向提交):
git tag -a -m ”标签描述”
查看远程标签列表:
git ls-remote --tags origin
删除远程标签:
git tag -d # 删除本地标签
git push origin --delete # 删除远程标签
发布版本时打标签:
git checkout main
git merge develop
git tag -a v2.1.0 -m ”版本2.1发布”
git push origin v2.1.0
为特定提交打标签:
git tag -a v1.2.3 7f3b4d5 # 7f3b4d5为提交哈希
git push origin v1.2.3
http://aigitlab.zj.chinamobile.com/data-engine/zcsnweb.git
http://aigitlab.zj.chinamobile.com/data-engine/zcsnfront.git
http://aigitlab.zj.chinamobile.com/data-engine/zcsnoperator.git
http://aigitlab.zj.chinamobile.com/data-engine/zcsnzckg.git
git remote set-url origin http://aigitlab.zj.chinamobile.com/data-engine/zcsnfront.git
Git 全局设置
git config --global user.name ”lxf17355297157”
git config --global user.email ”lxf17355297157@noreply.gitcode.com”
创建一个新仓库
git clone https://gitcode.com/lxf17355297157/lxftest.git
cd lxftest
echo ”# lxftest” >> README.md
git add README.md
git commit -m ”add README”
git branch -m main
git push -u origin main
推送现有的文件
cd existing_folder
git init
git remote add origin https://gitcode.com/lxf17355297157/lxftest.git
git add .
git commit -m ”Initial commit”
git branch -m main
git push -u origin main
推送现有的 Git 仓库
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitcode.com/lxf17355297157/lxftest.git
git push -u origin --all
git push -u origin --tags
git remote set-url origin http://aigitlab.zj.chinamobile.com/data-engine/zcsnfront.git
git checkout dev
git pull
git log
git push
git tag -a dev.20260104 485dba1960fa254853be04bd897e1155fa2efb42
git push origin dev.20260104
git checkout test
git pull
git log
git push
git tag -a test.20260104 485dba1960fa254853be04bd897e1155fa2efb42
git push origin test.20260104
git checkout main
git pull
git log
git push
git tag -a main.20260104 485dba1960fa254853be04bd897e1155fa2efb42
git push origin main.20260104
git checkout prod
git pull
git log
git push
git tag -a prod.20260104 485dba1960fa254853be04bd897e1155fa2efb42
git push origin prod.20260104