Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
git_move_uncommitted_changes_to_topic_branch [2019/03/12 15:14] – created rpjdaygit_move_uncommitted_changes_to_topic_branch [2019/03/12 15:20] (current) – [The steps] rpjday
Line 2: Line 2:
  
 How to move a pile of uncommitted changes from ''master'' to ''topic'', because they should have been on the ''topic'' branch in the first place. How to move a pile of uncommitted changes from ''master'' to ''topic'', because they should have been on the ''topic'' branch in the first place.
 +
 +===== The steps =====
 +
 +While still on ''master'', tag the current HEAD for reference later:
 +
 +<code>
 +$ git tag backup
 +</code>
 +
 +Commit all your work to ''master'' using reasonable commits for later:
 +
 +<code>
 +$ git add ...
 +$ git commit ...
 +
 +$ git add ...
 +$ git commit ...
 +</code>
 +
 +Switch to the other branch, which should work fine:
 +
 +<code>
 +$ git checkout topic
 +</code>
 +
 +Cherry-pick what you want from ''master'', or just all of it, dealing with merge conflicts as they arise:
 +
 +<code>
 +$ git cherry-pick backup..master
 +</code>
 +
 +Switch back to ''master'', wipe out those redundant commits, and delete the now superfluous tag:
 +
 +<code>
 +$ git checkout master
 +$ git reset --hard backup
 +$ git tag -d backup
 +</code>
 +
 +Note how you can reorganize the commits from ''master'' as you are cherry-picking them.
  • git_move_uncommitted_changes_to_topic_branch.1552403668.txt.gz
  • Last modified: 2019/03/12 15:14
  • by rpjday