我们推荐创建的Git仓库都包含一个README、LICENSE和.gitignore,这里将学习创建本地分支、远程仓库推送和修改远程仓库Url。
创建新仓库
| 12
 3
 4
 5
 6
 7
 
 | echo "# gitblog" >> README.mdgit init
 git add README.md
 git commit -m "first commit"
 git branch -M main
 git remote add origin git@github.com:fangjian98/gitblog.git
 git push -u origin main
 
 | 
推送本地仓库
| 12
 3
 
 | git remote add origin git@github.com:fangjian98/gitblog.gitgit branch -M main
 git push -u origin main
 
 | 
更新本地仓库 Remote Url
| 12
 3
 4
 5
 6
 
 | git remote -vgit remote remove origin
 git remote add origin https://gitcode.net/xxxx.git
 
 
 git remote add origin git@gitcode.net:xxxx.git
 
 | 
添加子模块
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 
 | 
 git rm --cached reference/esp-qcloud
 
 git rm -r --cached reference/esp-qcloud
 
 git rm -r -f --cached reference/esp-qcloud
 
 
 
 git submodule add <url> project
 
 git submodule add https://gitee.com/JavonPeng/project.git reference/esp-qcloud
 
 git submodule add git@gitee.com:JavonPeng/project.git reference/esp-qcloud
 
 添加成功后会生成.gitmodules文件,即添加子模块
 
 | 
查看仓库配置信息
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 
 | PS D:\CodeSpace\openAI> cat .\.git\config[core]
 repositoryformatversion = 0
 filemode = false
 bare = false
 logallrefupdates = true
 symlinks = false
 ignorecase = true
 [remote "origin"]
 url = git@github.com:fangjian98/openAI.git
 fetch = +refs/heads/*:refs/remotes/origin/*
 [branch "main"]
 remote = origin
 merge = refs/heads/main
 [branch "dev"]
 remote = origin
 merge = refs/heads/dev
 
 | 
配置远程仓库
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 
 | git pull <remote> <branch>
 
 
 git branch --set-upstream-to=origin/<branch> dev
 
 
 [branch "dev"]
 remote = origin
 merge = refs/heads/dev
 
 |