git分支命令及git push failed:remote ref does not exist问题解决

本文详细介绍Git中分支管理的基本操作,包括查看、创建、切换、推送和删除分支的方法,解决远程分支推送失败的问题,以及如何正确使用Git进行项目文件的上传。

1 在删除远程分支时出现git push failed:remote ref does not exist问题。
解决方案是清除远程分支的本地缓存:git fetch -p origin 其次确认当前git的所在项目文件位置。

2

  1. git branch -a #查看所有分支
  2. git branch -r #查看远程分支
  3. git checkout 分支名 #切换分支
  4. git branch 创建分支
  5. git checkout -b 分支名 #创建并切换到该分支=git branch +git checkout
  6. git push origin master(远程名)
  7. git push origin branch1:branch2 #从一个到另个上传分支
  8. git push origin --delete 分支名 #删除远程分支。
  9. git add 文件名 #指定的上传文件
Push failed, trying to delete existing migration branch first... Enumerating objects: 2863, done. Counting objects: 100% (2863/2863), done. Delta compression using up to 2 threads Compressing objects: 100% (737/737), done. Writing objects: 100% (2863/2863), 2.91 MiB | 1.51 MiB/s, done. Total 2863 (delta 2116), reused 2863 (delta 2116) remote: Resolving deltas: 100% (2116/2116) remote: error: branch refs/heads/migration: remote: You need 'Create' rights to create new references. remote: User: wuyilun1 remote: Contact an administrator to fix the permissions remote: Processing changes: refs: 1, done To ssh://gerrit/Tapo/base/vendor/CAMEOS/WIFI/MTK/mt7628 ! [remote rejected] add-mt7628 -> migration (prohibited by Gerrit: not permitted: create) error: failed to push some refs to 'ssh://gerrit/Tapo/base/vendor/CAMEOS/WIFI/MTK/mt7628' Fetching and checking out migration branch... fatal: couldn't find remote ref migration Failed to fetch migration branch, creating locally... Switched to branch 'migration' Establishing proper ancestry with re365v2_dev... fatal: couldn't find remote ref re365v2_dev Target branch is empty, no ancestry needed Pushing individual commits to Gerrit (using cached GPG passphrase)... remote: Processing changes: refs: 1, done To ssh://gerrit/Tapo/base/vendor/CAMEOS/WIFI/MTK/mt7628 ! [remote rejected] migration -> refs/for/re365v2_dev (branch re365v2_dev not found) error: failed to push some refs to 'ssh://gerrit/Tapo/base/vendor/CAMEOS/WIFI/MTK/mt7628' Debug: Extracted FIRST_COMMIT=, LAST_COMMIT= Warning: Could not extract commit range from Gerrit output Please check the push output above for commit numbers To approve changes manually, use: ./approve_changes.sh START_COMMIT-END_COMMIT Cleanup command (run after approval): git push mt7628 --delete migration Migration script completed!
12-11
remote: Resolving deltas: 100% (2116/2116) remote: error: branch refs/heads/migration: remote: You need 'Create' rights to create new references. remote: User: wuyilun1 remote: Contact an administrator to fix the permissions remote: Processing changes: refs: 1, done To ssh://gerrit/Tapo/base/vendor/CAMEOS/WIFI/MTK/mt7628 ! [remote rejected] add-mt7628 -> migration (prohibited by Gerrit: not permitted: create) error: failed to push some refs to 'ssh://gerrit/Tapo/base/vendor/CAMEOS/WIFI/MTK/mt7628' Fetching and checking out migration branch... fatal: couldn't find remote ref migration Failed to fetch migration branch, creating locally... Switched to branch 'migration' Establishing proper ancestry with refs/meta/config... remote: Counting objects: 3, done remote: Finding sources: 100% (3/3) remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), 404 bytes | 2.00 KiB/s, done. From ssh://gerrit/Tapo/base/vendor/CAMEOS/WIFI/MTK/mt7628 * branch refs/meta/config -> FETCH_HEAD Target branch is empty, no ancestry needed Pushing individual commits to Gerrit (using cached GPG passphrase)... remote: error: branch refs/for/refs/meta/config: remote: You need 'Create Change' rights to upload code review requests. remote: Verify that you are pushing to the right branch. remote: User: wuyilun1 remote: Contact an administrator to fix the permissions remote: Processing changes: refs: 1, done To ssh://gerrit/Tapo/base/vendor/CAMEOS/WIFI/MTK/mt7628 ! [remote rejected] migration -> refs/for/refs/meta/config (prohibited by Gerrit: not permitted: create change on refs/meta/config) error: failed to push some refs to 'ssh://gerrit/Tapo/base/vendor/CAMEOS/WIFI/MTK/mt7628' Debug: Extracted FIRST_COMMIT=, LAST_COMMIT= Warning: Could not extract commit range from Gerrit output Please check the push output above for commit numbers To approve changes manually, use: ./approve_changes.sh START_COMMIT-END_COMMIT Cleanup command (run after approval): git push mt7628 --delete migration Migration script completed!
最新发布
12-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值