Practical GIT (3) : Remove Specific commits
If you’are working with pilot project that many feature are experiment conditions, you need this feature, You can remove commits that you don’t want to exist in your revisions log. This feature named rebase. You can find the whole commits lists on range by typing :
git rebase -i HEAD~5
that command will show you last 5 commit and show them in the editor like the following :
pick 5c22314 third commit pick 8de60b5 fourth commit pick 9d3556f fifth commit pick 434ddc3 sixth commit pick d9b917g seventh commit # Rebase d9b917f..8de60b5 onto d9b917f # # 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 # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted. # ~ ~
If you want to remove fifth and sixth commit, just remove these two lines and save the editor ( if you’re working with vim, type ‘dd’ in the line you want to delete, and type ‘:wq!’. After do that, check by typing command :
git log
and you will get the result like the following ( fifth and sixth commit deleted ! )
commit d9b917g9d3556cfb0d0bbcd8ecd952cf4f358eea Author: Abdul Malik Ikhsan <samsonasik@gmail.com> Date: Wed Feb 20 15:47:13 2013 +0700 seventh commit commit 8de60b59d3556cd8eeafb0d0bbcd8ec952cf4f35 Author: Abdul Malik Ikhsan <samsonasik@gmail.com> Date: Wed Feb 20 15:47:13 2013 +0700 fourth commit commit 5c223149d3556cd952cf4f358eeafb0d0bbcd8ec Author: Abdul Malik Ikhsan <samsonasik@gmail.com> Date: Wed Feb 20 15:47:13 2013 +0700 third commit commit 5c2231434ddc3bac911ab38a22d2b47f5736f7d4 Author: Abdul Malik Ikhsan <samsonasik@gmail.com> Date: Wed Feb 20 15:46:50 2013 +0700 second commit commit d9b917f6a48eb9c0c415772f70b7c66adf3de0b5 Author: Abdul Malik Ikhsan <samsonasik@gmail.com> Date: Wed Feb 20 15:45:26 2013 +0700 first commit
With rebase, you can combine commits to/from other branch or squash commits with commands list while you get the list of commit via rebase -i command.
references :
1. http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html
Zend Framework 2 : Check Module Dependency
Zend Framework 2.0.7 and 2.1 were released! They come with new features and more improvements. One of the improvements is ability to check other module already loaded before. It provide Zend\ModuleManager\Feature\DependencyIndicatorInterface.
The sample code is like the following :
namespace Mod2; use Zend\ModuleManager\Feature\DependencyIndicatorInterface; class Module implements DependencyIndicatorInterface { public function getModuleDependencies() { return array('Mod1'); } public function getConfig() { /* common code here */ } public function getAutoloaderConfig() { /* common code here */ } }
If Mod1 is not loaded before Mod2, it will show the exception : Module “Mod2” depends on module “Mod1”
References :
1. https://github.com/zendframework/zf2/issues/3427
2. https://github.com/zendframework/zf2/pull/3443
leave a comment