Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
git:modules-with-history [2012/03/18 06:41] 109.230.216.60 ruJVuNvdy |
git:modules-with-history [2012/12/11 16:53] (current) oej old revision restored |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | No-they should | + | ====== Importing Modules With Full History Into Git ====== |
+ | |||
+ | Here is how you can import a kamailio module with full history (that means all | ||
+ | previous commits done on the svn will also be visible in git) into the | ||
+ | sip-router git repository. | ||
+ | |||
+ | First off, make sure you have a local copy of the sip-router git repository | ||
+ | with kamailio history merged into it. You can find a step-by-step guide | ||
+ | [[git: | ||
+ | |||
+ | I suppose that the module you want to import into the git repository will be | ||
+ | based on the sources present in the kamailio svn trunk, so as the next step | ||
+ | create a new branch based on the kamailio trunk: | ||
+ | < | ||
+ | $ git co -b sqlops_filtered km/trunk | ||
+ | </ | ||
+ | The name of the new branch is sqlops_filtered because I am importing kamailio | ||
+ | sqlops module, " | ||
+ | |||
+ | Like revision numbers in svn (and unlike versions in cvs), git commits, | ||
+ | identified by those cryptic sha1 hashes, record the state of __all__ files in | ||
+ | the source tree at the time when the commit was made. But this is a problem | ||
+ | because | ||
+ | all other files outside this directory. Even if you try to checkout an older | ||
+ | commit which changed only files within modules/ | ||
+ | source tree, including files of all other modules. There is no way you can get | ||
+ | a particular revision of selected files only--like you can do it with cvs. | ||
+ | |||
+ | But there is a solution: '' | ||
+ | (among other things) can walk through all commits in the history of the | ||
+ | current branch and tranform the commits into new commits with selected files | ||
+ | only. To include only files in modules/ | ||
+ | < | ||
+ | $ git-filter-branch --subdirectory-filter modules/ | ||
+ | </ | ||
+ | The command rewrite the history of the current branch, your current branch | ||
+ | should be " | ||
+ | you investigate the history of the branch with git log, you should see only | ||
+ | commits that are related | ||
+ | only one commit at the time of writing of this memo so don't be surprised | ||
+ | you only see one commit in the history). | ||
+ | |||
+ | If you examine your current working directory now, you'll notice that the | ||
+ | directory contains files from '' | ||
+ | need to put them back into modules/ | ||
+ | sip-router tree, this can be done with '' | ||
+ | can run the command second time, we need to remove some residual files from | ||
+ | the previous run: | ||
+ | < | ||
+ | $ rm -rf .git/ | ||
+ | </ | ||
+ | And the following command will move all the files back to '' | ||
+ | subdirectory: | ||
+ | < | ||
+ | $ git-filter-branch --index-filter 'git ls-files -s | | ||
+ | sed " | ||
+ | | ||
+ | mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' | ||
+ | </ | ||
+ | The previous command might look a little scary, but it is documented in '' | ||
+ | git-filter-branch'' | ||
+ | |||
+ | If you examine your current working directory now, it should contain modules | ||
+ | directory with sqlops subdirectory and all the module files there. This branch | ||
+ | is now ready to be merged into the sip-router tree, so create | ||
+ | for example sqlops, based on the sip-router master branch: | ||
+ | < | ||
+ | $ git co -b sqlops sr/master | ||
+ | </ | ||
+ | And now you can merge branch '' | ||
+ | < | ||
+ | $ git merge sqlops_filtered | ||
+ | </ | ||
+ | And if everything went well, congratulations, | ||
+ | first kamailio module into the sip-router git repository. Branch | ||
+ | " |