0

I don't know if I'm doing things right, obviously I'm not.

I'm new to rebasing. And I'm not exactly a master ninja guru at git overall yet...been doing it for a while but that was committing via merges, and now trying to stick with rebasing which I prefer going forward.

My problem: I can't seem to rebase again, I keep getting the errors you see below. updates were rejected. And the message doesn't really explain what happened, or how to solve it even though it probably does to some git gurus :).

I think what happened is I pushed code once without rebasing first and ended up with a detached head and ended up doing a merge instead of rebase. As you can see my tree isn't exactly in a straight line anymore:

You like that nice UI?  That's WebStorm baby! I do most my work via command-line but when I want to check out the tree, this is much nicer to see in.

enter image description here

Here are the steps I took which got me into this predicament: ``` branches/homepage xxxx-log-in ✔

ga .

branches/homepage  xxxx-log-in ✗  

gcmsg "removed proxy entry in package.json, was trying to troubleshoot API call"

    [xxxx-log-in 0fb184d] removed proxy entry in package.json, 
was trying to troubleshoot API call
     1 file changed, 6 deletions(-)

branches/homepage  xxxx-log-in ✔                                                                                                                                                                                                                                                             0m  

ga .

branches/homepage  xxxx-log-in ✔

git rebase -i develop

[detached HEAD bb5fdb3] problem with call to API - getting 403
 Date: Fri May 26 11:04:35 2017 -0500
 22 files changed, 185 insertions(+), 91 deletions(-)
 create mode 100644 src/client/reducers/AuthReducer.js
 create mode 100644 src/test/integration/api.integration.spec.js
 rename src/test/{unit => }/testImports.js (76%)
Successfully rebased and updated refs/heads/xxxx-log-in.

branches/homepage xxxx-log-in ✔

git push origin xxxx-log-in

To https://github.com/xxxx
 ! [rejected]        xxxx-log-in -> xxxx-log-in (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxxx'
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.

branches/homepage  xxxx-log-in ✔ 

git pull

There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> xxxx-log-in

branches/homepage  xxxx-log-in ✔

git pull origin xxxx-log-in

fatal: Couldn't find remote ref xxxx-log-in

branches/homepage  xxxx-log-in ✔

git push

fatal: The current branch xxxx-log-in has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin xxxx-log-in

branches/homepage  xxxx-log-in ✔

git push --set-upstream origin xxxx-log-in

To https://github.com/xxxx
 ! [rejected] xxxx-log-in -> xxxx-log-in (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxxx'
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.

branches/homepage  xxxx-log-in ✔

git status

On branch xxxx-log-in
nothing to commit, working tree clean

branches/homepage  w1-user-can-log-in ✔ 

git pull --ff-only

There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> xxxx-log-in

branches/homepage  xxxx-log-in ✔

git pull origin xxxx-log-in

From https://github.com/xxxx
 * branch            xxxx-log-in -> FETCH_HEAD
Auto-merging package.json
Merge made by the 'recursive' strategy.
 package.json | 6 ++++++
 1 file changed, 6 insertions(+)

branches/homepage  xxxx-log-in ✔

ga .

branches/homepage  xxxx-log-in ✗ 

▶ g**cmsg "removed proxy entry in package.json, was trying to

troubleshoot API call"**
[xxxx-log-in db91b96] removed proxy entry in package.json, was trying to troubleshoot API call
 1 file changed, 6 deletions(-)

branches/homepage  xxxx-log-in ✔ 

git rebase -i develop

[*detached* HEAD 47a599c] added integration test script to package.json
 Date: Fri May 26 11:15:25 2017 -0500
 2 files changed, 37 deletions(-)
 delete mode 100644 src/test/integration/api-integration-spec.js
Successfully rebased and updated refs/heads/xxxx-log-in.

branches/homepage  xxxx-log-in ✔  

git push origin xxxx-log-in

To https://github.com/xxxx
 ! [rejected]        xxxx-log-in -> xxxx-log-in (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxxx'
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.

branches/homepage  xxxx-log-in ✔ 

git checkout xxxx-log-in

Already on 'xxxx-log-in'

branches/homepage  xxxx-log-in ✔ 

git pull origin xxxx-log-in

From https://github.com/xxxx
 * branch            xxxx-log-in -> FETCH_HEAD
Auto-merging package.json
Merge made by the 'recursive' strategy.
 package.json | 6 ++++++
 1 file changed, 6 insertions(+) 

branches/homepage  xxxx-log-in ✔ 

git push

fatal: The current branch xxxx-log-in has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin xxxx-log-in

branches/homepage  xxxx-log-in ✔ 

git push --set-upstream origin xxxx-log-in

Counting objects: 10, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 1.26 KiB | 0 bytes/s, done.
Total 10 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), completed with 4 local objects.
To https://github.com/xxxx
   55aaad5..59507fb  xxxx-log-in -> xxxx-log-in
Branch w1-user-can-log-in set up to track remote branch xxxx-log-in from origin.     
branches/homepage  xxxx-log-in ✔ 

ga .

branches/homepage  xxxx-log-in ✗ 

gcmsg "removed proxy from package.json"

[xxxx-log-in 8f7363f] removed proxy from package.json
 1 file changed, 1 insertion(+), 6 deletions(-)

branches/homepage  xxxx-log-in ✔ 

git rebase -i develop

Successfully rebased and updated refs/heads/xxxx-log-in.

branches/homepage  xxxx-log-in ✔

git push origin xxxx-log-in

To https://github.com/xxxx
 ! [rejected]        xxxx-log-in -> xxxx-log-in (fetch first)
***error: failed to push some refs to 'https://github.com/xxxx'***
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.

branches/homepage  xxxx-log-in ✔ 

git pull origin xxxx-log-in

remote: Counting objects: 7, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 7 (delta 4), reused 7 (delta 4), pack-reused 0
Unpacking objects: 100% (7/7), done.
From https://github.com/xxxx
 * branch            xxxx-log-in -> FETCH_HEAD
   59507fb..4b13f34  xxxx-log-in -> origin/xxxx-log-in
Auto-merging package.json
Merge made by the 'recursive' strategy.
 package.json                                 | 6 ++++++
 src/test/integration/api.integration.spec.js | 9 ++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

branches/homepage  xxxx-log-in ✔

ga .

branches/homepage  xxxx-log-in ✗ 

gcmsg "removed all instances of session - not needed"

[xxxx-log-in d37a719] removed all instances of session - not needed
 5 files changed, 8 insertions(+), 13 deletions(-)

branches/homepage  xxxx-log-in ✔

git rebase -i develop

Successfully rebased and updated refs/heads/xxxx-log-in.

xxx/branches/homepage  xxxx-log-in ✔

git push origin xxxx-log-in

To https://github.com/xxxx
 ! [rejected]        xxxx-log-in -> xxxx-log-in (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxxx/xxx'
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. 
PositiveGuy
  • 17,621
  • 26
  • 79
  • 138

1 Answers1

0

you have 2 commits there if I assume the commit messages are unique.

To solve your issue, you need to:

git reset HEAD^2 # fix local history git push -fu origin xxxx-log-in # force push and set upstream on remote

This assumes you are still at the place from the screenshot.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
  • thx. When I tried the reset I got: atal: ambiguous argument 'HEAD^2': unknown revision or path not in the working tree. You probably meant HEAD~2? – PositiveGuy May 27 '17 at 20:03