Version Control System
Table of Contents
Bazzar
Bzr as Git
| Git | Bzr |
|---|---|
| git stash | bzr shelve –all |
| git stash apply | bzr unshelve |
Cherry picking
bzr merge BRANCH -c VER
GIT
spilt big repo to sub repos
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
- clone the repo:
git clone --no-hardlinks repo Documents
- Filter-branch:
cd Documents git filter-branch --subdirectory-filter Documents HEAD -- --all
- reset to exclude other files:
git reset --hard
- clean:
git gc --aggressive
- remove backup refs (
refs/original/*) Notice: the next steps are totally irreversible! but you have the original repogit for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
- expire your reflogs:
git reflog expire --expire=now --all
- remove unsed tags
git tag -d *
- 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
git --bare init --shared=group
git export
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 -lto 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 rebaseshould 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/reponamesvnadmin 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( orpatch -p0 < program-2.0.patch) - 撤销补丁:
cat program-2.0.patch | patch -p0 -R