Squashing commits
From OPeNDAP Documentation
⧼opendap2-jumptonavigation⧽
Squashing Commits of a branch to make things tidy
[nori:hello_world jimg$] git log commit 48a898d0830fbf8a795204993bbd572b83e6557c (HEAD -> hack, origin/hack) Merge: de1b5fe 1037dfa Author: James Gallagher <jgallagher@opendap.org> Date: Wed Sep 30 12:40:34 2020 -0600 Merge branch 'hack' of https://github.com/jgallagher59701/hello into hack commit de1b5fee05159d4a0ba35a189f12e94ba71dfe70 Author: James Gallagher <jgallagher@opendap.org> Date: Wed Sep 30 12:39:13 2020 -0600 Namespace finagling commit 1037dfa76b3bd8785b79f6f7a973209692f125a3 Author: James Gallagher <jgallagher@opendap.org> Date: Wed Sep 30 12:39:13 2020 -0600 Namespace finaggling commit 19c0052fea1162145d4ae483fc7cf07e61a244ab Author: James Gallagher <jgallagher@opendap.org> Date: Wed Sep 30 12:38:08 2020 -0600 Comments commit e6239975aaa6bf18d44a113873100df48d46087e Author: James Gallagher <jgallagher@opendap.org> Date: Wed Sep 30 12:37:40 2020 -0600 Added an error. commit f1302d5f3549937ddc770b06e7316fc11e5079ae (origin/master, master) Author: James Gallagher <jgallagher@opendap.org> Date: Wed Sep 30 12:32:19 2020 -0600 Initial commit
Use 'git rebase --interactive f1302d5f3'
Which will show (in the Git EDITOR):
pick e623997 Added an error. pick 19c0052 Comments pick de1b5fe Namespace finagling pick 1037dfa Namespace finaggling # Rebase f1302d5..48a898d onto f1302d5 (4 commands) # # 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 # d, drop = remove commit # # 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
Change the 'pick' word to 'squash'
pick e623997 Added an error. squash 19c0052 Comments squash de1b5fe Namespace finagling
Now we have:
[nori:hello_world jimg$] git log commit 94eba834437908e738f80c80403d2e95a6f11fe2 (HEAD -> hack) Author: James Gallagher <jgallagher@opendap.org> Date: Wed Sep 30 12:37:40 2020 -0600 Added an error. commit f1302d5f3549937ddc770b06e7316fc11e5079ae (origin/master, master) Author: James Gallagher <jgallagher@opendap.org> Date: Wed Sep 30 12:32:19 2020 -0600 Initial commit [nori:hello_world jimg$]
But... This won't work to push to GitHub because git will want us to pull first. To for the push, don't use `--force` but instead use this magic: 'git push origin +hack'. Yes, the magic is to include the word 'origin' and to use a plus sign, '+hack'.