Last active
August 29, 2015 14:01
-
-
Save tsnow/4fae18a07045f0dce033 to your computer and use it in GitHub Desktop.
Simple Git Rebase example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## tsnow: double comments added for clarity. | |
## Pull down the most recent changes to the repository. | |
~/dev/pim$ git fetch origin | |
remote: Counting objects: 120, done. | |
remote: Compressing objects: 100% (117/117), done. | |
remote: Total 120 (delta 20), reused 29 (delta 1) | |
Receiving objects: 100% (120/120), 302.27 KiB | 0 bytes/s, done. | |
Resolving deltas: 100% (20/20), done. | |
From github.com:ridecharge/pim | |
* [new branch] 1_6_2 -> origin/1_6_2 | |
16b6b63..28ec720 master -> origin/master | |
## Checkout the latest commit on the origin/1_6_2 branch | |
~/dev/pim$ git checkout origin/1_6_2 | |
HEAD is now at 50178fe... Made a slight change to 4g disable code, and added some more debug statements | |
## Apply the current branch (HEAD=origin/1_6_2)'s commits on top of origin/1_6_0's commits. | |
[50178fe...] ~/dev/pim$ git rebase -i origin/1_6_0 | |
## presents these commits, which are | |
## between origin/1_6_0 and origin/1_6_2, | |
## most of which are on master: | |
## BEGIN EDITOR WINDOW: | |
pick 5ba9c41 improvements to the set password scripts and rcsender | |
pick 7e08822 improvements to the set password scripts and rcsender | |
pick 2f630e9 added scripts to get Pos version/md5 from remote pim | |
pick 92ca67a modified ride stats script | |
pick dfbbd6d added script to compute average ride times | |
pick 894fc35 added script to upload pdp data as a log file | |
pick 48ee5fa changed rcsender to be able to run a specific job | |
pick 2798f60 added script files to rcutil | |
pick 6bee61f added feature to run specific job in rcsender, fixed delay time in rcitelnet | |
# pick c15adfd Fixed gps satilite count function | |
# pick 15f3187 fixed modem rssi reading at command | |
pick 984c6ef added feature to pdpinspect to print the bytes | |
pick 5efe5df PA-XX refactorred CMS code for the new cms3 stuff | |
pick 2d5d26f PA-XX refactorred CMS code for the new cms3 stuff | |
pick 16b1ae0 cbs-demo development | |
pick d68fdd7 saved pim_upload_pdp_v2.sh script | |
pick 6808af9 fixed blue tooth compiler bug about taking an address of a temp | |
pick 26649c6 fixed gcc 4.6 compiler error with ssl struct. | |
pick 22121fd CMS3 Banners, cbs changes | |
pick 0f63e2c new pim forms implementation | |
pick 9332106 connected impressions to pim forms | |
pick c26eb5a No const, breaking the build | |
pick 3b9b1b0 clean up compiler problems | |
pick d0bf1ee added librss | |
pick e2b0fc4 tools for converting spreadsheets to xml files | |
pick bb75dd5 added features to mkmanifest to support s3 url | |
pick c22a55e able to spec the output file name in mkmanifest | |
pick a52e481 removed previous compiler fix as it causes a crash...thought this code was unused...we need to remove the ripsd code | |
pick 28fa846 removed previous compiler fix as it causes a crash...thought this code was unused...we need to remove the ripsd code | |
pick e38b053 fixed bug in debug message...accessed null pointer | |
pick a81d128 full screen adjustment | |
pick 221306a typo and turned on content window debug | |
pick 3442609 added a feature to allow additional mplayer options | |
pick 6eb7b82 fixed bug in full sceeen mode | |
pick 830234d fixed bug in full sceeen mode | |
pick d5a1d61 turned off debug and set build data | |
pick 763970a fixed xml tool | |
pick 56e969c Bump POS Version | |
pick 7d69496 handled quotes | |
pick 934821c handles xml encoding | |
pick 4456a45 fixed a bug in volume control during content play, turned off debug msgs, updated build date | |
pick f63da0d Added man2html tool | |
pick 16b6b63 fixed parsing error in cvs2xml | |
pick e616b99 Background RemoteSync and Scheduled updates | |
pick b35c366 Worked on disabling 4g for modems, via c++ code | |
pick 50178fe Made a slight change to 4g disable code, and added some more debug statements | |
# Rebase b2fe297..50178fe onto b2fe297 | |
# | |
# Commands: | |
# p, pick = use commit | |
# r, reword = use commit, but edit the commit message | |
# e, edit = use commit, but stop for amending | |
# s, squash = use commit, but meld into previous commit | |
# f, fixup = like "squash", but discard this commit's log message | |
# x, exec = run command (the rest of the line) using shell | |
# | |
# These lines can be re-ordered; they are executed from top to bottom. | |
# | |
# If you remove a line here THAT COMMIT WILL BE LOST. | |
# | |
# However, if you remove everything, the rebase will be aborted. | |
# | |
# Note that empty commits are commented out | |
## END EDITOR WINDOW | |
## Make that look like this | |
## ("Just the commits that are on origin/1_6_2 but not on origin/master"): | |
## BEGIN EDITOR WINDOW: | |
pick b35c366 Worked on disabling 4g for modems, via c++ code | |
pick 50178fe Made a slight change to 4g disable code, and added some more debug statements | |
## END EDITOR WINDOW | |
## Save the file | |
Successfully rebased and updated detached HEAD. | |
## Show what the current branches look like on my local repo at the moment: | |
## origin/1_6_0: | |
[f90c730...] ~/dev/pim$ git log -n 1 --oneline origin/1_6_0 | |
b2fe297 Fixed bug in pdptransmit that caused files > 4k to get corrupted as they were sent | |
## origin/master: | |
[f90c730...] ~/dev/pim$ git log -n 2 --oneline origin/master | |
28ec720 fix bug interduced in last build that didnt reset the playlist and disabled comercial full screen escape | |
e616b99 Background RemoteSync and Scheduled updates | |
## origin/1_6_2: | |
[f90c730...] ~/dev/pim$ git log -n 4 --oneline origin/1_6_2 | |
50178fe Made a slight change to 4g disable code, and added some more debug statements | |
b35c366 Worked on disabling 4g for modems, via c++ code | |
e616b99 Background RemoteSync and Scheduled updates | |
16b6b63 fixed parsing error in cvs2xml | |
## Current branch: (note that the 4g commits have different | |
## hashes than on the origin/1_6_2 branch. This is what is meant by 'modifying history'.) | |
[f90c730...] ~/dev/pim$ git log -n 3 --oneline | |
f90c730 Made a slight change to 4g disable code, and added some more debug statements | |
b32a8ec Worked on disabling 4g for modems, via c++ code | |
b2fe297 Fixed bug in pdptransmit that caused files > 4k to get corrupted as they were sent | |
## Simulate what the condition on everyone else's computer will be: | |
~/dev/pim$ git checkout 1_6_2 | |
## Set the origin/1_6_2 branch to the f90c730 commit that's on top of 1_6_0 | |
## f90c730 Made a slight change to 4g disable code, and added some more debug statements | |
[1_6_2] ~/dev/pim$ git push origin f90c730:1_6_2 | |
To [email protected]:ridecharge/pim.git | |
! [rejected] f90c730 -> 1_6_2 (non-fast-forward) | |
error: failed to push some refs to '[email protected]:ridecharge/pim.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. | |
## Good. git push doesn't let you modify history unless you force it to. | |
## Force it to modify the branch destructively. | |
[1_6_2] ~/dev/pim$ git push origin f90c730:1_6_2 -f | |
Counting objects: 37, done. | |
Delta compression using up to 8 threads. | |
Compressing objects: 100% (9/9), done. | |
Writing objects: 100% (9/9), 1.37 KiB | 0 bytes/s, done. | |
Total 9 (delta 6), reused 1 (delta 0) | |
To [email protected]:ridecharge/pim.git | |
+ 50178fe...f90c730 f90c730 -> 1_6_2 (forced update) | |
## Show how the current checked-out local 1_6_2 branch is different than the origin/1_6_2 branch: | |
[1_6_2] ~/dev/pim$ git log -n 1 --oneline | |
50178fe Made a slight change to 4g disable code, and added some more debug statements | |
[1_6_2] ~/dev/pim$ git log -n 1 --oneline origin/1_6_2 | |
f90c730 Made a slight change to 4g disable code, and added some more debug statements | |
## Point the local 1_6_2 branch at the origin/1_6_2 commit instead, | |
## and change any local files which would have changed in the process. | |
## (i.e. make the working copy act as if we'd just done a merge between two commits) | |
[1_6_2] ~/dev/pim$ git reset origin/1_6_2 --merge | |
[1_6_2] ~/dev/pim$ git status | |
On branch 1_6_2 | |
Your branch is up-to-date with 'origin/1_6_2'. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment