Russell Bateman
February 2014
last update:
These are to be added to gitk.html or somewhere better. (Some notes in that file aren't relevant to gitk and should be put elsewhere.)
Imagine having done work a couple of files in a private branch, russ, consisting of several commits and pushes to origin russ, then needing to present the work in a code review. For convenience, you want the changes to appear as being the object of a single commit.*
(* Because of how change messages are expected to appear in the product repository with "reviewed by" notices and there's only going to be one review.)
This isn't the best way, but it allowed some useful exploration along the way.
Here's the history...
1 gitk --all 2 git checkout master 3 git pull origin master 4 git checkout russ 5 git merge master 6 git rebase --interactive HEAD~10 7 git rebase --abort 8 git reset --soft 611f07eb50c2c36f0370d114846f2164b0602142 9 git reset --hard 611f07eb50c2c36f0370d114846f2164b0602142 10 git rebase --interactive HEAD~4 11 git push origin russ 12 git reset --soft HEAD^
This is the best (and shortest) way to have produced the effect we were looking for (without all the trial, error and exploration noted above). It's not an exact subset of the above, but includes a couple of other likely operations.
1 gitk --all 2 git rebase --interactive HEAD~4 3 git log 4 git reset --soft HEAD^ 5 git status 6 git commit -a
1 git checkout master 2 git pull origin master 3 git checkout russ 4 git rebase --interactive master 5 gitk --all & 6 git status 7 git commit -a 8 git rebase --interactive master 9 git fetch 10 git checkout master 11 git merge russ 12 git push origin master 13 git checkout russ 14 git fetch 15 git push origin --delete russ
This is to help visualize what actually went on.
russ ~/fs/ct $ git checkout master M fs-api/src/test/java/org/familysearch/fs/api/sources/TestFsReferenceType.java M fsbe-domain/domain-prod/src/test/java/org/familysearch/ct/impl/sources/TestFsReferenceServiceImplForCmisWrite.java Switched to branch 'master' Your branch is ahead of 'origin/master' by 6 commits. master ~/fs/ct $ git pull origin master remote: Counting objects: 3, done. remote: Compressing objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. From github.com:fs-eng/ct * branch master -> FETCH_HEAD Updating 4fa22e6..0694949 Fast-forward integration.properties | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) master ~/fs/ct $ git checkout russ M fs-api/src/test/java/org/familysearch/fs/api/sources/TestFsReferenceType.java M fsbe-domain/domain-prod/src/test/java/org/familysearch/ct/impl/sources/TestFsReferenceServiceImplForCmisWrite.java Switched to branch 'russ' russ ~/fs/ct $ git rebase --interactive master Cannot rebase: You have unstaged changes. Additionally, your index contains uncommitted changes. Please commit or stash them. russ ~/fs/ct $ gitk --all & [1] 3048 russ ~/fs/ct $ git status # On branch russ # ... # # modified: fs-api/src/test/java/org/familysearch/fs/api/sources/TestFsReferenceType.java # modified: fsbe-domain/domain-prod/src/test/java/org/familysearch/ct/impl/sources/TestFsReferenceServiceImplForCmisWrite.java # # Changes not staged for commit: # (use "git add..." to update what will be committed) # (use "git checkout -- ..." to discard changes in working directory) # # modified: fsbe-domain/domain-prod/src/test/java/org/familysearch/ct/impl/sources/TestFsReferenceServiceImplForCmisWrite.java # russ ~/fs/ct $ git commit -a [russ 31717a7] Added test for new method in FsReference. Refactored TestFsReferenceServiceImpl forCmisWrite. 2 files changed, 627 insertions(+), 1293 deletions(-) rewrite fsbe-domain/domain-prod/src/test/java/org/familysearch/ct/impl/sources/TestFsReferenceServiceImplForCmisWrite.java (64%) russ ~/fs/ct $ git rebase --interactive master Successfully rebased and updated refs/heads/russ. russ ~/fs/ct $ git fetch remote: Counting objects: 10, done. remote: Compressing objects: 100% (10/10), done. remote: Total 10 (delta 0), reused 3 (delta 0) . . . russ ~/fs/ct $ git checkout master Switched to branch 'master' master ~/fs/ct $ git merge russ Updating 0694949..993a2df Fast-forward .../fs/api/sources/TestFsReferenceType.java | 6 + .../TestFsReferenceServiceImplForCmisWrite.java | 1040 ++++---------------- 2 files changed, 190 insertions(+), 856 deletions(-) master ~/fs/ct $ git push origin master Counting objects: 42, done. Delta compression using up to 8 threads. Compressing objects: 100% (17/17), done. Writing objects: 100% (23/23), 2.74 KiB, done. Total 23 (delta 10), reused 0 (delta 0) To [email protected]:fs-eng/ct.git 0694949..993a2df master -> master master ~/fs/ct $ git checkout russ Switched to branch 'russ' russ ~/fs/ct $ git fetch russ ~/fs/ct $ git push origin --delete russ To [email protected]:fs-eng/ct.git - [deleted] russ
git fetch says what has changed since—it doesn't pull anything down as does git pull.