首页 > 其他分享 >git 关联 github、gitee 仓库

git 关联 github、gitee 仓库

时间:2023-01-19 14:11:24浏览次数:54  
标签:origin git pay gitee github main Think

github 官网创建仓库,取得仓库地址,我的这个是  https://github.com/xue-y/pay.git 

 

gitee 官网点击创建仓库,右上角 新建导入,进入导入页面

 选择语言,点击导入 按钮

  本地克隆远程仓库 

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW
$ git clone [email protected]:xue-y/pay.git
Cloning into 'pay'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), 4.46 KiB | 415.00 KiB/s, done.

 

查看远程仓库地址

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git remote -v
origin  [email protected]:xue-y/pay.git (fetch)
origin  [email protected]:xue-y/pay.git (push)

 

复制 gitee 仓库地址

 添加 gitee 仓库地址

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git remote add gitee_origin [email protected]:xue-y/pay.git

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git remote -v
gitee_origin    [email protected]:xue-y/pay.git (fetch)
gitee_origin    [email protected]:xue-y/pay.git (push)
origin  [email protected]:xue-y/pay.git (fetch)
origin  [email protected]:xue-y/pay.git (push)

 

添加测试文件

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git status
On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        test.txt

nothing added to commit but untracked files present (use "git add" to track)

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git add test.txt

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git commit -m '测试提交文件'
[main 8eb8d41] 测试提交文件
 1 file changed, 1 insertion(+)
 create mode 100644 test.txt

 

查看默认仓库,当前 main 分支  追踪 origin 这个远程主机,main 这个远程分支

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git branch -vv
* main 8eb8d41 [origin/main] 测试提交文件

设置追踪关系 ,如:本地名称为 master 要追踪到远程origin/master  git branch --set-upstream-to=origin/master master 

 

push/pull   要分别提交,  git push  提交默认(存在追踪关系的)仓库,提交 gitee 仓库需要指定 远程仓库名称

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git push
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 314 bytes | 104.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:xue-y/pay.git
   a3fe3e0..8eb8d41  main -> main

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git push gitee_origin main
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 314 bytes | 62.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To gitee.com:xue-y/pay.git
   a3fe3e0..8eb8d41  main -> main

 

push和pull无需额外操作,一次提交,不用分别提交两次仓库

不添加 gitee 远程仓库,而是给 github 添加额外的 URL。使用git remote set-url -add ,给已有的名为name的远程仓库添加一个远程地址,比如:

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git remote set-url --add origin [email protected]:xue-y/pay.git
Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git remote -v
gitee_origin    [email protected]:xue-y/pay.git (fetch)
gitee_origin    [email protected]:xue-y/pay.git (push)
origin  [email protected]:xue-y/pay.git (fetch)
origin  [email protected]:xue-y/pay.git (push)
origin  [email protected]:xue-y/pay.git (push)

 

添加测试文件

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git status
On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        test2.txt

nothing added to commit but untracked files present (use "git add" to track)

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git add  test2.txt

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git commit -m '测试提交一次文件'
[main 39050fc] 测试提交一次文件 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test2.txt

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git status
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git push
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 363 bytes | 45.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:xue-y/pay.git
   f25589c..39050fc  main -> main
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 363 bytes | 121.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To gitee.com:xue-y/pay.git
   f25589c..39050fc  main -> main

 

 删除 gitee 仓库

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git remote rm gitee_origin  // 删除远程仓库 gitee_origin 

Think@Think-PC MINGW64 /f/phpStud/PHPTutorial/WWW/pay (main)
$ git remote -v
origin  [email protected]:xue-y/pay.git (fetch)
origin  [email protected]:xue-y/pay.git (push)
origin  [email protected]:xue-y/pay.git (push)

标签:origin,git,pay,gitee,github,main,Think
From: https://www.cnblogs.com/xuey/p/17061324.html

相关文章

  • git_test
    项目的开发是一个不断迭代的过程,开发过程中程序员需要不断的对代码进行编写和更正。这就带来很多的问题。首先,开发中代码会存在多个版本,我们如何将代码在多个版本间进行切......
  • Hugo + Github 静态托管自己博客
    详情hugo:官网地址Go-lang:官网地址Git:官网地址辅助工具->GithubProxy:官网地址......
  • 用Gitbash将整个文件上传到github
    试过很多的方法,但发现就这个适用于我 1.先找到想上传的文件夹,进入该文件夹,右键gitbash-here 2.在gitbash界面输入gitclonehttps://XXXX.git即你要上传的仓库链接......
  • git blame All In One
    gitblameAllInOnegit高级教程gitblame$git--help#'githelp-a'and'githelp-g'listavailablesubcommandsandsomeconceptguides.#See'githe......
  • GitHub - 电脑无法访问GitHub
    通过下面网址查询最新的IP地址:https://github.com.ipaddress.comhttps://www.ipaddress.com然后配置到host中202103IP地址为:140.82.112.3windows:Windows电脑有时打不......
  • 【版本控制工具】Git急速入门
    文章目录1.Git简介1.1.什么是Git1.2.Git与SVN区别2.Git工作流程2.1.Git的工程流程3.Git工作区、暂存区和版本库3.1.Git工作区、暂存区和版本库4.Git创建仓库4.......
  • Git命令帮助
    GIT命令初始化配置配置全局用户名:gitconfig--globaluser.name'yeluo'配置全局邮箱:gitconfig--globaluser.email'[email protected]'初始化仓库:gitinit配置......
  • Gitlab集成jenkins及docker自动化部署教程
    Gitlab集成jenkins及docker自动化部署教程能实现提交代码到gitlab后,我们只需要合并代码到指定分支就可以上Jenkins自动拉取最新代码并重新构建部署1、登录Jenkins点击如......
  • Windows GIT SSH 免密教程
    1.安装git客户端下载地址:https://github.com/git-for-windows/git/releases/download/v2.23.0.windows.1/Git-2.23.0-64-bit.exe2.安装好后,在桌面右键出现GitGUIhere和......
  • Linux Jenkins安装配置Git
    1.卸载自带的gitapt-getremovegit2.验证是否卸载git--version3.下载git并将git添加到环境变量中wgethttps://github.com/git/git/archive/v2.2.1.tar.gz或者直接在......