Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git 如何将本地仓库中上传一个本地有但是远程没有的分支? #25

Open
QiYongchuan opened this issue Jun 30, 2023 · 1 comment
Labels
Kill-bugs The tools i kill bugs

Comments

@QiYongchuan
Copy link
Owner

问题描述:

我在本地有一个仓库StydyPy,用来记录我的学习代码,我要上传到我的远程项目仓库Let’s Run中。

思路:本地有master分支,远程则是main分支,现在我要建一个StudyPy上去,一是我直接把我的master分支改名字,然后上传到远程仓库,或者我在本地新建一个StudyPy分支,然后将master分支里的内容,merge过去,再上传到远程仓库。

因为远程仓库并没有StudyPy的分支,无论哪种方法,也需要在远程新建一个分支,即原来不存在的分支。

新建-复制思路
image

重命名思路:
image

将本地推送到远程:

image

以上是说,当远程有仓库的时候,git push origin StudyPy 就可以;如果远程没有,那就git push -u origin StudyPy,意思是先建一个,再传过去。

当然,把本地仓库push到远程的前提是,两者建立了关联:

image

@QiYongchuan QiYongchuan added the Kill-bugs The tools i kill bugs label Jul 2, 2023
@QiYongchuan
Copy link
Owner Author

QiYongchuan commented Mar 25, 2024

#65 git远程分支:如何将本地分支与远程分支相关联

参考最新的博客:可以将本地存在但远程不存在的分支上,上传并且关联;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Kill-bugs The tools i kill bugs
Projects
None yet
Development

No branches or pull requests

1 participant