Table of Contents
svn
Svn ignore
This technique is more like .gitignore than .git/info/excludes (Managing svn:ignore with impunity):
Create a svnignore in the top of your project. Make a list of files/wildcards you care to ignore Save it
Now, from the top of your project, you can do:
svn propset svn:ignore -F svnignore .
At least this way you have to make just 1 propset change.
You'll still have to either track or ignore your .svnignore (just like .gitignore).
vim svnignore
autom4te.cache
build
tags
tmp
prefix
# Compiled Object files
*.slo
*.lo
*.o
# Compiled Dynamic libraries
*.so
*.dylib
# Compiled Static libraries
*.lai
*.la
*.a
# http://www.gnu.org/software/automake
Makefile.in
# http://www.gnu.org/software/autoconf
/autom4te.cache
/aclocal.m4
/compile
/configure
/depcomp
/install-sh
/missing
# Subfolders
*/.deps
*/.dirstamp
svn commit -m "update svnignore"
svn delete on repo only
svn delete http://www.yourrepository.com/svn/folder --message "Deleting"
Svn commit deleted files
svn delete xyz svn commit -m "deleted xyz"
If forget svn?
svn update svn delete ...
Delete repo only
svn delete --keep-local the_file
If files deleted by script, e.g., make distclean.
svn status
(!) means files deleted locally.
! config.h ! config.log ! config.status ! doc/Makefile ! examples/Makefile ! examples/npp-client/.deps ! examples/npp-client/.deps/npp-client.Po ! examples/npp-client/Makefile
svn delete file in that list svn commit -m "clean up file deletion after make distclean"
revert
svn update -r <earlier_revision_number>
Get latest revision number
svn info -r 'HEAD'
Branching & merging
Creating branches
Use copy:
$ cd bigwc $ svn copy trunk branches/my-calc-branch $ svn status A + branches/my-calc-branch <--- the +-sign indicates copy operation not new!
Or better:
$ svn copy http://svn.example.com/repos/calc/trunk \
http://svn.example.com/repos/calc/branches/my-calc-branch \
-m "Creating a private branch of /calc/trunk."
Committed revision 341.
Using branch
$ svn checkout http://svn.example.com/repos/calc/branches/my-calc-branch A my-calc-branch/Makefile A my-calc-branch/integer.c A my-calc-branch/button.c Checked out revision 341.
Undo commiting bad stuffs
Determine the point in history where you started committing bad stuff (say revision “100” while you are at “130”)
svn copy trunk branch # create your branch while preserving history svn copy trunk@100 trunk #replace current revision with revision 100
This should bypass the bad history without adding a reverse merge (actually you are bypassing the history of the trunk between 100 and 130 but you kept a link to that history in the branch and accessing trunk while forcing the rev will still yield the correct history)
Then
svn switch branch workdir
this should work if you want to completely remove the changes from trunk. If there are small ones you want to keep you can cherry pick them again from branch to trunk (if you use svn 1.5 it will track merge points and avoid spurious conflicts)
Return to older version
Return from r28 to r24:
svn merge -r 28:24
Replace trunk with branch
Do this out side local svn clone.
svn copy <repos/trunk> <repos/tag/old_trunk> -m "copied old trunk as tag" svn delete <repos/trunk> -m "deleted trunk temporarily" svn copy <repos/branch/new_fetaure_branch> <repos/trunk> -m "placed new trunk with features"
Merge
Sync Branch with Trunk
root svn_root/{trunk, branch/td}
[branch_td]$svn merge ^/trunk . --- Merging r5939 through r5970 into '.':
More information
branch I always have to look up the documentation on how to merge a whole SVN branch to another. Today there were bug fixes to trunk of my project that I wanted to port into my branch. I expected this to be easy since I hadn’t made many changes to my branch, and no changes to the same files that were modified in the trunk. Using Common Use-Cases as a reference, this is what I did: From within my branch: svn log This displays the revision number for when my branch was created: ------------------------------------------------------------------------ r23 | stereosv | 2009-02-17 11:42:28 -0500 (Tue, 17 Feb 2009) | 1 line creating branch for xyz Now I need to find out what revision number the trunk is at. Perfoming an “svn update” within the trunk shows me what version it’s at. > svn update At revision 25. In my case the trunk is at revision 25… implying there were only two commits since the time I checked out my branch. Nice. Now, it’s time to carry merge these changes into my branch. Back in my branch directory, it’s time to put these revision numbers to good use. svn merge -r 23:25 svn+ssh://username@svnserver/home/username/svn/project/trunk What this does is merge the changes that were made between revision 23 (when I created my branch) and revision 25 (the most recent revision of the trunk) in the trunk into my working copy. Now, it’s time to check in my branch, with the updated changes from the trunk. svn ci -m "Merged trunk changes r23:25 into my branch" SVN 1.5 has made some improvements to the way merging works.. So check your SVN version with “svn –version” to make sure you are using the right syntax for your version.
svn copy trunk pre_merge_trunk cd branch svn merge pre_merge_trunk test build: branch is what we want?
Sync Trunk with Branch
Conflicts
Use either version
- (mc) - accept my version for all conflicts (same) [mine-conflict]
- (tc) - accept their version for all conflicts (same) [theirs-conflict]
- (mf) - accept my version of entire file (even non-conflicts) [mine-full]
- (tf) - accept their version of entire file (same) [theirs-full]
Manually resolve conflict
Choose to postpone the conflict. Both version appear marked in the conflicting file. Edit the file then tell svn that the conflict is resolved:
svn resolve --accept=working README
Update again to see if there is another conflict.
svn update
Finally, commit
svn commit -m file_name svn commit file_name # open editor to edit comment.
Create patch
svn diff > ~/fix_ugly_bug.diff patch -p0 -i ~/fix_ugly_bug.diff
svn export: Get source code from other repo
Do this:
svn export /path/to/old/working/copy /path/to/plain/code cd openwrt/packages/libllcp svn export https://cvs.dai-labor.de/svn/emobility/charging-station/SNEP/libllcp src
Or checkout and remove all .svn recursively
svn co https://cvs.dai-labor.de/svn/emobility/charging-station/SNEP/libllcp src find . -iname ".svn" -print0 | xargs -0 rm -r svn add src svn commit -m "add libllcp"
Import project
This imports the local directory myproj into trunk/misc in your repository. The directory trunk/misc need not exist before you import into it—svn import will recursively create directories for you.
Don't use this read on…
$ svn import -m "New import" myproj \
http://svn.red-bean.com/repos/trunk/misc
Adding myproj/sample.txt
Transmitting file data .........
Committed revision 16.
Be aware that this will not create a directory named myproj in the repository. If that's what you want, simply add myproj to the end of the URL:
$ svn import -m "New import" myproj \
http://svn.red-bean.com/repos/trunk/misc/myproj
Adding myproj/sample.txt
…
Transmitting file data .........
Committed revision 16.
After importing data, note that the original tree is not under version control. To start working, you still need to svn checkout a fresh working copy of the tree.