Changes between Version 4 and Version 5 of GitUsage


Ignore:
Timestamp:
12/05/10 12:55:37 (8 years ago)
Author:
magnate
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GitUsage

    v4 v5  
    2424This typically happens when you're engrossed in working on your commit and haven't noticed that someone else has pushed an update to the branch you're working on in the meantime. So you finish testing your work, commit it and to 'git push remotename branchname', only to get told  
    2525 
    26 {{{To git@github.com:angband/angband.git 
     26{{{ 
     27To git@github.com:angband/angband.git 
    2728 ! [rejected]        staging -> staging (non-fast-forward) 
    2829error: failed to push some refs to 'git@github.com:angband/angband.git' 
    2930To prevent you from losing history, non-fast-forward updates were rejected 
    3031Merge the remote changes (e.g. 'git pull') before pushing again.  See the 
    31 'Note about fast-forwards' section of 'git push --help' for details.}}} 
     32'Note about fast-forwards' section of 'git push --help' for details. 
     33}}} 
    3234 
    3335Argh. You don't want to lose your changes, but you also don't want to do a non-fast-forward merge and risk the wrath of takk ... so try this:  
    3436 
    35 {{{git fetch remotename 
     37{{{ 
     38git fetch remotename 
    3639git checkout remotename/branchname 
    3740git checkout -b newbranch 
    3841git cherry-pick your-commit-id 
    39 git push remotename newbranch:branchname}}} 
     42git push remotename newbranch:branchname 
     43}}} 
    4044 
    4145That creates a new copy of the branch you're tracking, adds your commit without recursing, and pushes it upstream as if you'd done it right in the first place. All that's left is to tidy up your local repo: delete both the old messed-up branch with the right name and the new branch with the wrong name, and re-create the properly-named branch to track the remote one.