赞
踩
如果本地同样一份代码,已经关联了一个与远程分支,那么怎么才能解除原程分支,并关联到一个新的分支将代码提交到新的分支上去呢?
1、如果你已经在远程创建了一个分支,远程分支地址:https://xxxxxxx/wangdong/helloworld.git
2、从命令行创建一个新的仓库,关联到该远程分支
- touch README.md
- git init
- git add README.md
- git commit -m "first commit"
- git remote add origin https://xxxxxxx/wangdong/helloworld.git
- git push -u origin master
3、如果本地的代码,没有关联任何远程分支
- git remote add origin https://xxxxxxx/wangdong/helloworld.git
- git push -u origin master
4、如果本地代码,已经关联了远程分支,则需要先解除关联
git remote remove origin
5、解除后、重新关联新的远程分支,并将代码传上去
- ~/dev33/alioss-file on master ⌚ 10:44:56
- $ git remote add origin https://dev.33.cn/wangdong/alioss-file.git
- ~/dev33/alioss-file on master ⌚ 10:45:01
- $ git push -u origin master
- Counting objects: 102, done.
- Delta compression using up to 8 threads.
- Compressing objects: 100% (82/82), done.
- Writing objects: 100% (102/102), 62.52 KiB | 7.81 MiB/s, done.
- Total 102 (delta 26), reused 0 (delta 0)
- To https://dev.33.cn/wangdong/alioss-file.git
- * [new branch] master -> master
- Branch master set up to track remote branch master from origin.
6、完成
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。