UP | HOME

Version Control System

Table of Contents

Bazzar

Bzr as Git

GitBzr
git stashbzr shelve –all
git stash applybzr unshelve

Cherry picking 2012-02-23 Thu

bzr merge BRANCH -c VER

GIT

spilt big repo to sub repos 2012-05-17 Thu

I have a big repo for all my private stuff, including tex files, org files, and some small projects. After 3 years, the repo becomes really big and slow (due to share file with windows, the repo is put in the NTFS disk). I decide to spilt them to three projects: Documents, projects, and publichtml (which are three subfolder in my repo). What I did are (use Documents as example) follow:

steps

  1. clone the repo:
    git clone --no-hardlinks repo Documents
    
  2. Filter-branch:
    cd Documents
    git filter-branch --subdirectory-filter Documents HEAD  -- --all
    
  3. reset to exclude other files:
    git reset --hard
    
  4. clean:
    git gc --aggressive
    
  5. remove backup refs (refs/original/*) Notice: the next steps are totally irreversible! but you have the original repo
    git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
    
  6. expire your reflogs:
    git reflog expire --expire=now --all
    
  7. remove unsed tags
    git tag -d *
    
  8. delete the now-unused objects
    git gc --prune=now
    

And now, I have all my files from repo/Documents in Documents, really cool.

Known issues

  • all the tags are lost

setup Shared Repository with SSH access 2012-04-23 Mon

git --bare init --shared=group

git export 2011-05-16 Mon

git archive master | tar -x -C /somewhere/else

git gc

For some reasons, the git gc can not compress loose objects, use git gc --prune to delete them. ( But according to manual of git, the prune action is on by default, and the objects older than two weeks should be deleted. )

Create a patch and apply to source code [Apr 10, 2010]

  • create a branch, modfiy codes, commit in
  • create a patch: git format-patch master --stdout > branch_name.patch
  • apply the patch: patch -p1 < branch_name.patch

Changing SVN repository address [Apr 10, 2010]

From GitSvnSwitch

  • Back up your git repo. If you make a mistake with repository rewriting you'll be in for a lot of fun.
  • Edit the svn-remote url URL in .git/config to point to the new domain name
  • Run git svn fetch - **This needs to fetch at least one new revision from svn!**
  • Change svn-remote url back to the original url
  • Run git svn rebase -l to do a local rebase (with the changes that came in with the last fetch operation)
  • Change svn-remote url back to the new url
  • Run git svn rebase should now work again!

Recover 'lost' stash [Mar 9, 2010]

When create the new stash, the old one disappears in the revision tree of gitk, but in fact git do not remove them.

$ git stash list lists all the stash!!

$ git stash apply <stash> apply the <stash> (e.g. stash@{0} is the most recently created stash, stash@{1} is the one before it, stash@{2.hours.ago} is also possible)

Merging binary files [Feb 11, 2010]

$ git checkout --ours path/to/conflicted-file

or

$ git checkout --theirs path/to/conflicted-file

Subversion

create a temp svn repository

  • svnadmin create /path/to/reponame
  • svnadmin load /path/to/reponame < /tmp/repo1.dump
  • edit /path/to/reponame/conf/svnserver.conf anon-access = none password-db = passwd
  • edit /path/to/reponame/conf/passwd user = password
  • svnserver -d -r /path/to/reponame

Merging a whole branch to trunk

  • $ cd branch
  • $ svn log --stop-on-copy // get the revision in which the branch is created
  • $ cd trunk
  • $ svn update
  • $ svn merge -r ???:HEAD http://brach // ??? is the revision in which the branch is created
  • reslove the conflicts … examine the diffs, compile, test, etc….
  • $ svn commit -m "Merged brach changes r???:???? into trunk."

diff/patch

  • 生成补丁: diff -Nur program-1.0 program-2.0 > program-2.0.patch
  • 打上补丁: cat program-2.0.patch | patch -p0 ( or patch -p0 < program-2.0.patch )
  • 撤销补丁: cat program-2.0.patch | patch -p0 -R

© 2012-05-17 22:26:36 CEST Xu Yuan (xuyuan.cn@gmail.com) Proudly powered by Org version 7.8.10 with Emacs version 24. Validate XHTML 1.0