将本地代码文件夹作为新分支添加到远程仓库

将本地代码文件夹作为新分支添加到远程仓库

在windows系统下使用Git,想要将本地代码文件夹作为新分支添加到远程仓库,经过个人实践,验证以下操作有效:

1.      在代码文件夹右键GitBash Here

2.      Git仓库初始化:  git init

3.      将文件夹中代码添加到仓库: git add .

4.      提交  git Commit  -m “说明”

5.      建立分支 git  branch  Testbranch(该分支是基于master创建的,所以只有做完步骤3、4才可以建立分支)

6.      切换到新建的分之不上 :gitcheckout Testbranch

7.      添加远程仓库链接:

运行 git remote add <shortname> <url> 添加一个新的远程 Git 仓库,同时指定一个你可以轻松引用的简写(pb):

$ git remote

origin

$ git remote addpb https://github.com/paulboone/ticgit

$ git remote -v

origin      https://github.com/schacon/ticgit (fetch)

origin      https://github.com/schacon/ticgit (push)

pb           https://github.com/paulboone/ticgit (fetch)

pb           https://github.com/paulboone/ticgit (push)

                                                            

8.      gitpush  - -set-upstream pb Testbranch(远程仓库分支与本地同名)

此时可以在远程仓库看到新的分之 Testbranch。

猜你喜欢

转载自blog.csdn.net/zhanghao519/article/details/53520761
今日推荐