我有一个主要分支" dev ",我签出了一个基于dev的分支"A“。
问题是为什么dev是由我的本地开发人员更新的,如果我在本地A分支上执行git推力的话。
# BSDC-587_For_EMC_test has been merged to dev on server, and deleted on server
# Made some modifications and commit
$ git status
On branch BSDC-587_For_EMC_test
Your branch is ahead of 'dummy-ondemand/dev' by 5 commits.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: ../rtos/ssp/app/svc/config/AmbaCamCtrl.c
modified: ../rtos/ssp/app/svc/main/AmbaOpModeCtrlTask.c
Untracked files:
(use "git add <file>..." to include in what will be committed)
pkg/network_turnkey/source/usr/local/share/script/emc_download.sh
../rtos/mcu_image/bsd_mcu.bin
no changes added to commit (use "git add" and/or "git commit -a")
$ git add ../rtos/ssp/app/svc/config/AmbaCamCtrl.c
$ git add ../rtos/ssp/app/svc/main/AmbaOpModeCtrlTask.c
$ git branch
* BSDC-587_For_EMC_test
dev
$ git commit -m "BSDC-578 add network checking and downloading"
[BSDC-587_For_EMC_test 85f42e7] BSDC-578 add network checking and downloading
2 files changed, 33 insertions(+), 4 deletions(-)
// Try to push local branch to server, but it seems like git try to push dev branch
$ git push
To ssh://git@bitbucket.org/dummy-ondemand/tsdk-code.git
! [rejected] dev -> dev (fetch first)
error: failed to push some refs to 'ssh://git@bitbucket.org/dummy-ondemand/tsdk-code.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
$ cd ..
$ git pull
remote: Counting objects: 148, done.
remote: Compressing objects: 100% (148/148), done.
remote: Total 148 (delta 132), reused 0 (delta 0)
Receiving objects: 100% (148/148), 157.20 KiB | 0 bytes/s, done.
Resolving deltas: 100% (132/132), completed with 53 local objects.
From ssh://bitbucket.org/dummy-ondemand/tsdk-code
b2de179..9a75859 dev -> dummy-ondemand/dev
* [new branch] BSDC-592_store_IMSI_to_flash_at_boot -> dummy-ondemand/BSDC-592_store_IMSI_to_flash_at_boot
+ 07459ca...531ec19 BSDC_faster_time_to_first_picture -> dummy-ondemand/BSDC_faster_time_to_first_picture (forced update)
Auto-merging rtos/ssp/app/svc/main/AmbaOpModeCtrlTask.c
CONFLICT (content): Merge conflict in rtos/ssp/app/svc/main/AmbaOpModeCtrlTask.c
Recorded preimage for 'rtos/ssp/app/svc/main/AmbaOpModeCtrlTask.c'
Automatic merge failed; fix conflicts and then commit the result.
$ git status
On branch BSDC-587_For_EMC_test
Your branch and 'dummy-ondemand/dev' have diverged,
and have 6 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
You have unmerged paths.
(fix conflicts and run "git commit")
Changes to be committed:
modified: rtos/bsp/trailcam/bsp.c
modified: rtos/bsp/trailcam/ringbuffer.c
modified: rtos/bsp/trailcam/ringbuffer.h
modified: rtos/ssp/app/svc/AmbaUserSysCtrl.c
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: rtos/ssp/app/svc/main/AmbaOpModeCtrlTask.c
Untracked files:
(use "git add <file>..." to include in what will be committed)
ambalink_sdk_4_9/pkg/network_turnkey/source/usr/local/share/script/emc_download.sh
rtos/mcu_image/bsd_mcu.bin
$ vi rtos/ssp/app/svc/main/AmbaOpModeCtrlTask.c
$ git add rtos/ssp/app/svc/main/AmbaOpModeCtrlTask.c
$ git commit
Recorded resolution for 'rtos/ssp/app/svc/main/AmbaOpModeCtrlTask.c'.
[BSDC-587_For_EMC_test a46f1b9] Merge branch 'dev' of ssh://bitbucket.org/dummy-ondemand/tsdk-code into BSDC-587_For_EMC_test
ldy2534@ubuntu:~/Project/project_mcu/context/tekdev/tsdk-code$ git status
On branch BSDC-587_For_EMC_test
Your branch is ahead of 'dummy-ondemand/dev' by 7 commits.
(use "git push" to publish your local commits)
Untracked files:
(use "git add <file>..." to include in what will be committed)
ambalink_sdk_4_9/pkg/network_turnkey/source/usr/local/share/script/emc_download.sh
rtos/mcu_image/bsd_mcu.bin
nothing added to commit but untracked files present (use "git add" to track)
$ git branch
* BSDC-587_For_EMC_test
dev
ldy2534@ubuntu:~/Project/project_mcu/context/tekdev/tsdk-code$ git rebase dev
First, rewinding head to replay your work on top of it...
Applying: BSDC-587 EMC test wifi working version
Applying: BSDC-587 improve network connection
Applying: BSDC-587 tidy up code
Applying: BSDC-578 add more comments
Applying: BSDC-587 modifications according to review
Applying: Merged in BSDC-510_fix_x_uart_lost_messages (pull request #178)
Applying: Merged in BSDC-587_For_EMC_test (pull request #177)
Using index info to reconstruct a base tree...
M ambalink_sdk_4_9/pkg/bsd_app/tekipc_projectlink.cpp
M ambalink_sdk_4_9/pkg/bsd_app/tekipc_projectlink.h
M ambalink_sdk_4_9/pkg/bsd_app/xsmtp.cpp
M ambalink_sdk_4_9/pkg/bsd_app/xsmtp.h
M rtos/bsp/trailcam/devices.h
M rtos/ssp/app/svc/bsd_app/tekipc_bsd.cpp
M rtos/ssp/app/svc/bsd_app/tekipc_bsd.h
M rtos/ssp/app/svc/config/AmbaCamCtrl.c
M rtos/ssp/app/svc/format/AmbaMovMuxer.c
M rtos/ssp/app/svc/main/AmbaOpModeCtrlTask.c
M rtos/ssp/app/svc/main/AmbaPostProc.c
M rtos/ssp/app/svc/main/AmbaRecTask.c
M rtos/ssp/app/svc/main/DemoTask.c
M rtos/ssp/app/svc/main/inc/AmbaPostProc.h
M rtos/ssp/app/svc/main/inc/AmbaSVC.h
.git/rebase-apply/patch:86: trailing whitespace.
return false;
.git/rebase-apply/patch:665: trailing whitespace.
.git/rebase-apply/patch:588: new blank line at EOF.
+
.git/rebase-apply/patch:671: new blank line at EOF.
+
warning: 4 lines add whitespace errors.
Falling back to patching base and 3-way merge...
No changes -- Patch already applied.
Applying: BSDC-578 add network checking and downloading
$ tig
$ git status
On branch BSDC-587_For_EMC_test
Your branch and 'dummy-ondemand/dev' have diverged,
and have 7 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
Untracked files:
(use "git add <file>..." to include in what will be committed)
ambalink_sdk_4_9/pkg/network_turnkey/source/usr/local/share/script/emc_download.sh
rtos/mcu_image/bsd_mcu.bin
nothing added to commit but untracked files present (use "git add" to track)
$ git add ambalink_sdk_4_9/pkg/network_turnkey/source/usr/local/share/script/emc_download.sh
$ git commit -m "BSDC-578 add emc_download script"
[BSDC-587_For_EMC_test a0983d0] BSDC-578 add emc_download script
1 file changed, 5 insertions(+)
create mode 100755 ambalink_sdk_4_9/pkg/network_turnkey/source/usr/local/share/script/emc_download.sh
$ git push
To ssh://git@bitbucket.org/dummy-ondemand/tsdk-code.git
! [rejected] dev -> dev (non-fast-forward)
error: failed to push some refs to 'ssh://git@bitbucket.org/dummy-ondemand/tsdk-code.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
$ git push --force
Total 0 (delta 0), reused 0 (delta 0)
remote:
remote: Create pull request for dev:
remote: https://bitbucket.org/dummy-ondemand/tsdk-code/pull-requests/new?source=dev&t=1
remote:
To ssh://git@bitbucket.org/dummy-ondemand/tsdk-code.git
+ 9a75859...b2de179 dev -> dev (forced update)
$ git branch
* BSDC-587_For_EMC_test
dev发布于 2019-08-23 15:54:44
如您所见,BSDC-587_For_EMC_test分支旁边有一个星号。当您预编好git拉时,它还从服务器上提取了dev分支。如果你愿意的话:
$ git checkout dev回到您的代码,我想您会发现它根本没有从您的本地分支更新。
发布于 2019-08-23 19:06:10
在第一个git status中,它显示:
On branch BSDC-587_For_EMC_test
Your branch is ahead of 'dummy-ondemand/dev' by 5 commits.马上就有什么不对劲了。您的本地分支将dummy-ondemand/dev集作为其上游分支。这意味着(默认情况下)任何git push命令(强制或其他方式)都将尝试更新dummy-ondemand/dev。
很明显,这不是你想要发生的。不知道你是如何创建这个分支的,也不知道你所做的事情的全部历史,就不可能知道你是如何进入这个状态的。
修复当前问题
git checkout BSDC-587_For_EMC_test -切换到正确的分支git branch --unset-upstream -将当前的上游关联移除到devgit push -u dummy-ondemand BSDC-587_For_EMC_test -在远程dummy-ondemand上创建分支BSDC-587_For_EMC_test并将本地上游设置为该分支现在,git push不会导致对dummy-ondemand/dev的更改。
https://stackoverflow.com/questions/57625344
复制相似问题