提交工程到git的分支上

git提交工程到分支上

将本地仓库的内容提交到远程仓库分支上,本示例在window下测试使用,Linux系统大同小异。

1. 初始化本地仓库

git init

2. 将本地内容添加到git

git add .   //将当前目录下的所有文件添加进提交内容

3. 创建提交说明

git commit -m "第一次提交"

4. 关联远程仓库

git remote add origin https://github.com/用户名/仓库名

5. 获取远程仓库分支情况

git fetch
git branch -a

6.创建本地新分支

git branch XRROS-APP

7. 推送本地分支到远程分支上

git checkout XRROS-APP   //切换本地分支到XRROS-APP上,默认是master
git push origin XRROS-APP:XRROS-APP

注意:前一个XRROS-APP是本地分支,后一个是远程分支
如果在push的时候,出现以下错误:

To https://github.com/yuanchao614/wecoder.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/yuanchao614/wecoder.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

出现以上的non-fast-forward错误,请执行以下指令

 git pull origin 分支名称 --allow-unrelated-histories

可能会出现vim编辑不用管直接保存退出就行
然后建议做完上一步之后再重新:

git add .
git commit -m '提交说明'
git push origin XRROS-APP:XRROS-APP

如果出现以下内容,则表明推送成功了

$ git push origin XRROS-APP:XRROS-APP
Enumerating objects: 586, done.
Counting objects: 100% (586/586), done.
Delta compression using up to 4 threads
Compressing objects: 100% (553/553), done.
Writing objects: 100% (584/584), 12.38 MiB | 395.00 KiB/s, done.
Total 584 (delta 76), reused 0 (delta 0)
remote: Resolving deltas: 100% (76/76), done.
To https://github.com/xxx/XiaoR-ROS
   a904c7f..169a2bd  XRROS-APP -> XRROS-APP

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值