Git切换分支并提交到远程分支

1. 在本地需要提交的文件同级目录运行git bash

2. 初始化 git 运行环境

$ git init

3. 新建本地分支develop

$ git checkout -b decelop

4. 链接远程仓库

$ git remote add origin remote_address   

5. 同步远程仓库信息

$ git pull

 

6. 关联本地仓库与远程仓库

$ git branch --set-upstream-to=origin/develop develop

7. 若遇报错: branch 'develop' does not exist

则运行如下指令:

$ git pull origin branch --allow-unrelated-histories
$ git branch --set-upstream-to=origin/develop develop

8. 查看当前分支跟踪的远程分支

$ git branch -vv

9. 同步远程分支

$ git pull

 

10. 提交修改到远程分支

$ git add .
$ git commit -m "modify description"
$ git push

 

posted @ 2019-06-18 09:58  北辰Root  阅读(8034)  评论(0编辑  收藏  举报