首先
git remote add origin 远程仓库
添加正确的远程仓库URL,并设置跟踪
git branch
将当前的
1 | main |
分支重命名并设置跟踪远程的
1 | debug-podcast-creation |
分支
git fetch origin
1 | From https://github.com/tju-tomorrow/ |
成功获取了远程仓库的信息,包括debug-podcast-creation分支。现在让我们将本地的main分支重命名为debug-podcast-creation并设置它跟踪远程的debug-podcast-creation分支:
git branch -m main debug-podcast-creation
已经将本地分支重命名为debug-podcast-creation,接下来需要设置它跟踪远程的debug-podcast-creation分支:
git branch –set-upstream-to=origin/debug-podcast-creation debug-podcast-creation
总结
1 | git fetch origin |
- 这个命令从远程仓库获取最新的信息
获取到了两个分支的信息
1.
1 | git branch -m main debug-podcast-creation |
这个命令用来重命名分支
-m
1
2
3
4
5
6
7
8
9
10
11
12
13
是"move"的缩写,意思是移动或重命名
- 把原来的main分支重命名为debug-podcast-creation
- 就像是把原来的文件夹改个名字
git branch --set-upstream-to=origin/debug-podcast-creation debug-podcast-creation
- 这个命令设置本地分支和远程分支的关联
- ```
--set-upstream-to
意思是设置”上游分支”
就是告诉Git:当我说
1
git push
或
1
git pull
时,应该和远程的
1
debug-podcast-creation
分支进行交互