简体   繁体   中英

Git branches diverged and cannot push changes

I am currently in a branch and trying to push changes to my branch on bitbucket. I get this error:

! [rejected] fixing_tests -> fixing_tests (non-fast-forward) error: failed to push some refs to 'https://<url to my bitbucket repo>.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (eg hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

and I also get this when I switch to my branch:

Your branch and 'origin/fixing_tests' have diverged, and have 4 and 10 different commits each, respectively. (use "git pull" to merge the remote branch into yours)

Problem with git pull or re-branching

I want my changes to be pushed to my bit bucket branch, but I do not want to pull. If I git pull then it will pull down code that will break my tests (hard to explain).

I also can't copy my work, delete the branch, and rebranch from dev because dev is currently not working.

Outcome?

The branch I am on now works perfectly...not sure what to do to be able to keep my current branches state and successfully push to bitbucket without pulling down the broken code.

Any help is appreciated sorry that it is so messy with my predicament.

If all you want to do is save your commits somewhere else, save them to a branch with a different name on Bitbucket:

git push origin fixing_tests:HyeEun-branch

for instance. You can also rename your own branch name, or make a new branch name in your Git repository. Except for the git push and git fetch operations—when you have your Git call up some other Git, over at Bitbucket in this case—the names you use are not important. The only thing that your Git really cares about is your commits (by hash ID).

Whenever you git push , your Git will send your commits (by hash ID) to the other Git, then ask them to set some name in their Git repository. It's the name that is giving you this problem right now, so you can work around it by using some other name in their Git repository (whether or not you use this same name in your own Git repository).

So I was pushing via git push and not git push origin facepalm and that's why they separated.

fixed it with git push origin +branch_name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM