Git 同步到新库/更换仓库

进行git初始化
git init
将本地代码添加到仓库
git add ./注意有空格
git commit -m “上传仓库时的说明”
关联上远程仓库
git remote add origin https://github.com/DavidCuii/react-ts-app.git
最后将你的代码上传到Git库
git push -u origin master

更换仓库
第一: 查看远程库的信息: git remote -v
第二: 删除现有的远程仓库: git remote rm origin
第三: 建立新的远程仓库地址: git remote add origin + 远程仓库地址

There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

当出现这个问题时,是因为本地分支和远程分支没有建立联系,可以先指定本地master到远程的master,然后再去pull

git branch --set-upstream-to=origin/master master
git pull

  

posted @ 2023-05-11 14:46  文采呱呱  阅读(44)  评论(0编辑  收藏  举报