Skip to content

Instantly share code, notes, and snippets.

@DanBradbury
Last active August 29, 2015 14:17
Show Gist options
  • Save DanBradbury/e6168536a0b29ad2709c to your computer and use it in GitHub Desktop.
Save DanBradbury/e6168536a0b29ad2709c to your computer and use it in GitHub Desktop.
Rebase -i without fear

Do this in your own branches and not on master

~/Documents/Invoca/web on ⭠ 81/eb/STORY-2324_add_failover_node_ui ⌚ 17:28:16
$ git rebase -i ac28fc8~1                                                                                                                  
# will open up your configd editor of choice and you will be presented with a menu.

I typically use edit because I like to stop at every individual commit and ensure the changes are correct by doing a git commit --ammend and then continuing with the rebase with git rebase --continue.

  1. git commit --ammend
  2. Update commit message
  3. git rebase --continue
  4. Repeat until rebase is completed
~/Documents/Invoca/web on ⭠ 8bddf1d ⌚ 17:37:57
$ git rebase --continue                                                                                                        2.1.2
Successfully rebased and updated refs/heads/81/eb/STORY-2324_add_failover_node_ui.

We are done with the rebase but git push won't work

~/Documents/Invoca/web on ⭠ 81/eb/STORY-2324_add_failover_node_ui ⌚ 17:38:01
$ git push                                                                                                                     2.1.2
To [email protected]:Invoca/web.git
 ! [rejected]        81/eb/STORY-2324_add_failover_node_ui -> 81/eb/STORY-2324_add_failover_node_ui (non-fast-forward)
error: failed to push some refs to '[email protected]:Invoca/web.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.

Instead we have to use git push origin branch_name -f and the repo should get updated immediately

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment