четверг, 11 апреля 2013 г.

SVN GIT MERCURIAL comparison cheatsheet



Git command
Hg command


git pull
hg fetch
hg pull -u


git fetch
hg pull


git push
hg push -r .


git checkout <commit>
hg update -c <cset>


git checkout [<rev>] -- <file(s)>
hg revert [-r <rev>] <file(s)>


git reset --hard
hg revert -a --no-backup


git revert <commit>
hg backout <cset>


git add <new_file>
hg add <new_file>


git add <file>
git reset HEAD <file>


git add -i
hg record


git commit --amend
hg commit --amend or
hg rollback ; hg commit or
hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip 


git rebase --interactive
hg histedit <base cset>


git stash
hg shelve


git merge
hg merge


git cherry-pick <commit>
hg transplant <cset>
hg graft <csets>


git rebase <upstream>
hg rebase -d <cset>


git format-patch <commits> and git send-mail
hg email -r <csets>


git am <mbox>
hg mimport -m <mbox>


git describe
hg log -r . --template '{latesttag}-{latesttagdistance}-{node|short}\n'


git describe rev
hg log -r rev --template '{latesttag}-{latesttagdistance}-{node|short}\n'


git log origin..HEAD
git log origin/foobranch..HEAD
hg outgoing


git fetch && git log HEAD..origin
hg incoming


git show rev
hg export rev


git show hash:file
hg cat -r rev file


git ls-files
hg manifest


git log
hg log


git log -n
hg log --limit n


git ??
hg summary


git status
hg outgoing
hg status


git remote add -f remotename url


git remote update remotename
hg pull remotename


git branch -a
hg branches


git config --global user.(name|email) ...


git clean or
git status --porcelain|sed -r 's:\?\?\s(.*):\1:g'|xargs rm
hg purge or
hg status -un|xargs rm

Mercurial Cheat

Основные команды

HG INIT (CREATE в SVN) - Создать хранилище файлов в HG
hg init




HG CLONE (CHECKOUT в SVN) - Выгрузка файлов из хранилища HG на локальный компьютер
hg clone
 


HG STATUS (STATUS в SVN) - Посмотреть статус внесенных измененийhg status




HG ADD (ADD в SVN) - Пометка файлов и папок для будущего добавления в хранилище в HG

hg add file.txt


HG REMOVE (DELETE в SVN) - Пометка файлов и папок для будущего удаления из хранилища SVN

hg remove file.txt


HG DIFF (DIFF в SVN) - Посмотреть (сравнить) внесенные в проект изменения

Показать различия между текущей рабочей директорией и той же директорией в хранилище

hg diff


HG COMMIT (COMMIT в SVN) - Отправка (добавление) внесенных изменений из локальной папки в хранилище HG

hg commit -m "Comment Saving recent changes"


HG PUSH - отправить измения в удаленный репозиторий

hg push


HG PULL (UPDATE в SVN) - Выгрузка последней версии файлов из хранилища HG с целью обновления локальных файлов и их замены на файлы из хранилища

hg pull


HG UPDATE (UPDATE в SVN) - Выгрузка последней версии файлов из хранилища HG с целью обновления локальных файлов и их замены на файлы из хранилища

hg update


HG LOG (LOG в SVN) - Посмотреть кто еще переносил свои изменения в хранилище HG

hg log


===============================================================

Git command
Hg command

git pull
hg fetch
hg pull -u

git fetch
hg pull

git push
hg push -r .

git checkout <commit>
hg update -c <cset>

git checkout [<rev>] -- <file(s)>
hg revert [-r <rev>] <file(s)>

git reset --hard
hg revert -a --no-backup

git revert <commit>
hg backout <cset>

git add <new_file>
hg add <new_file>

git add <file>
git reset HEAD <file>

git add -i
hg record

git commit --amend
hg commit --amend or
hg rollback ; hg commit or
hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip 

git rebase --interactive
hg histedit <base cset>

git stash
hg shelve

git merge
hg merge

git cherry-pick <commit>
hg transplant <cset>
hg graft <csets>

git rebase <upstream>
hg rebase -d <cset>

git format-patch <commits> and git send-mail
hg email -r <csets>

git am <mbox>
hg mimport -m <mbox>

git describe
hg log -r . --template '{latesttag}-{latesttagdistance}-{node|short}\n'

git describe rev
hg log -r rev --template '{latesttag}-{latesttagdistance}-{node|short}\n'

git log origin..HEAD
git log origin/foobranch..HEAD
hg outgoing

git fetch && git log HEAD..origin
hg incoming

git show rev
hg export rev

git show hash:file
hg cat -r rev file

git ls-files
hg manifest

git log
hg log

git log -n
hg log --limit n

git ??
hg summary

git status
hg outgoing
hg status

git remote add -f remotename url

git remote update remotename
hg pull remotename

git branch -a
hg branches

git config --global user.(name|email) ...

git clean or
git status --porcelain|sed -r 's:\?\?\s(.*):\1:g'|xargs rm
hg purge or
hg status -un|xargs rm

GIT Cheat


Основные команды

GIT INIT (CREATE в SVN) - Создать хранилище файлов в Git

git init


GIT CLONE (CHECKOUT в SVN) - Выгрузка файлов из хранилища Git на локальный компьютер

git clone ssh://user@domain.com/repo.git


GIT STATUS - Посмотреть статус внесенных изменений

git status


GIT ADD . - Пометка файлов и папок для будущего добавления в хранилище в Git

git add .

Другой пример

git add -p my_file.txt


GIT RM (DELETE в SVN) - Пометка файлов и папок для будущего удаления из хранилища SVN

git rm file_or_directory_inside_my_project_folder


GIT DIFF - Посмотреть (сравнить) внесенные в проект изменения

Показать различия между текущей рабочей директорией и той же директорией в хранилище

git diff


GIT COMMIT -A (COMMIT в SVN) - Отправка (добавление) внесенных изменений из локальной папки в хранилище Git

git commit -a

Другой пример

git commit


GIT PULL (UPDATE в SVN) - Выгрузка последней версии файлов из хранилища Git с целью обновления локальных файлов и их замены на файлы из хранилища

git pull

Другой пример

git checkout rev
git checkout prevbranch


GIT LOG - Посмотреть кто еще переносил свои изменения в хранилище GIT

git log

Другой пример

git log -p my_file.txt


GIT TAG (COPY в SVN) - Тэгирование (копирование) и создание отдельных версий проекта в хранилище Git

Тэги создают отдельные копии проекта для будущих изменений.
В директори tags создается виртуальная копия проекта.

git tag -a my_tag_name


===============================================================

Дополнительные команды

GIT CHECKOUT (REVERT в SVN) - Отменить внесенные изменения
git checkout


===============================================================

GIT COMMANDS SUMMARY

0. BASICS

master - default development branch
origin - default upstream repository

HEAD - current branch
HEAD^ - parent of HEAD
HEAD~4 - the great-great grandparent of HEAD


1. CREATE

FROM EXISTING DATA

cd ~/projects/myproject
git init
git add .

FROM EXISTING REPOSITORY

git clone ~/existing/repository ~/new/repository

git clone git://host.org/project.git

git clone ssh://you@host.org/project.git


2. BROWSE

SHOW FILES CHANGED IN LOCAL WORKING DIRECTORY

git status

SHOW CHANGES TO TRACKED FILES

git diff

SHOW WHAT CHANGES BETWEEN FILE 1 AND FILE 2

git diff file1.txt file2.txt

SHOW HISTORY OF CHANGES

git log

SHOW HISTORY OF CHANGES FOR FILE WITH DIFFS

git log -p file.txt /some/directory/

SHOW WHO CHANGED WHAT AND WHEN IN A FILE

git blame file.txt

SHOW COMMIT IDENTIFIED BY ID

git show 1467

SHOW FILE FROM A SPECIFIC COMMIT

git show 1467:file.txt

SHOW ALL LOCAL BRANCHES

git branch


3. CHANGE


4. REVERT

RETURN TO THE LAST COMMITTED STATE

git reset --hard

REVERT THE LAST COMMIT

git revert HEAD

REVERT THE SPECIFIC COMMIT

git revert 1467

FIX THE LAST COMMIT

git commit -a --amend

CHECKOUT THE VERSION OF A FILE

git checkout 1467 file.txt


5. UPDATE

FETCH LATEST CHANGES FROM ORIGIN UPSTREAM REPOSITORY

git fetch

PULL LATEST CHANGES FROM ORIGIN UPSTREAM REPOSITORY

git pull

APPLY A PATCH THAT SOMEONE SENT TO YOU

git am -3 patch.mbox


6. BRANCH

SWITCH TO THE BRANCH

git checkout 1467

MERGE BRANCH 1 INTO BRANCH 2

git checkout branch2
git merge branch1

CREATE BRANCH NAMED SOMEBRANCH BASED ON HEAD

git branch somebranch

CREATE BRANCH NEWBRANCH BASED ON BRANCH OTHERBRANCH AND SWITCH TO IT

git checkout -b newbranch otherbranch

DELETE BRANCH

git branch -d somebranch


7. PUBLISH


COMMIT ALL YOUR LOCAL CHANGES

git commit -a

PREPARE A PATCH FOR OTHER DEVELOPERS

git format-patch origin

PUSH CHANGES TO ORIGIN

git push

MARK A VERSIION / MILESTONE

git tag v1.0


RESOLVE MERGE CONFLICTS

TO VIEW MERGE CONFLICTS

git diff
git diff --base file.txt
git diff --ours file.txt
git diff --thirs file.txt

TO DISCARD CONFLICT PATCH

git reset --hard
git rebase --skip

AFTER RESOLVING CONFLICTS, MERGE WITH

git add conflict_file.txt
git rebase --continue

VIM Cheat

Movement
h - left j - down k - up l - right
$ - end of line 0 - Beginning of line
w - forward one word b -- back one word e - end of the current word
Return -- Moves down to the beginning of the next line
^d - down half a screen ^u - up half a screen
^f -- Pages forward one screen ^b -- Pages back one screen
G -- Goes to the last line of the file 1G -- Goes to the first line of the file
:21 -- Goes to line 21 21G -- Goes to line 21

Insert and Delete
x - delete character X - delete previous character
dd - delete line dw - delete word D - delete to eol
i - insert at cursor a - append after cursor A - append at eol
o - open line below O - open line above
:5,10d -- Deletes lines 5 through 10

Searching
/string -- Searches forward for the string ?string -- Searches backward for the string
n -- Finds the next occurrence N -- Finds the previous occurrence
:%s/old/new/g -- Searches and replaces globally

Copy, Move, Manipulate
J - join next line
ayy -- Yanks a copy of line to buffer a
a7yy -- Yanks next 7 lines into buffer a
"ap -- Put the contents of buffer a after cursor
"aP -- Put the contents of buffer a before cursor
:1,3 co 5 -- Copies lines 1 through 3 and puts them after line 5
:4,6 m 8 -- Moves lines 4 through 6 to line 8 (line 6 becomes line 8, line 5 becomes line 7, and line 4 becomes line 6)
:r filename -- Inserts (reads) the file at line after the cursor

Saving and Quitting
:w -- Saves changes (write buffer)
:w new_filename -- Writes buffer to new_filename
:wq -- Saves changes and quits vi
:x -- Saves changes and quits vi
ZZ -- Saves changes and quits vi
:q! -- Quits without saving changes
:wq! -- Saves changes and quits vi (the ! overrides read-only permissions for the owner of the file only)

Set Command Options
:set nu -- Shows line numbers
:set nonu -- Hides line numbers
:set ic -- Instructs searches to ignore case
:set noic -- Instructs searches to be case-sensitive
:set list -- Displays invisible characters, such as tab and end-of-line
:set nolist -- Turns off the display of invisible characters
:set showmode -- Displays current mode of operation
:set noshowmode -- Turns off mode display
:set -- Displays all vi variables set
:set all -- Displays all possible vi variables and their current settings

SVN Cheat

abbeyworkshop.com/howto/misc/svn01/
jwamicha.wordpress.com/2008/05/29/subversion-a-summary-cheat-sheet-learn-svn-in-10-minutes/

===============================================================

Основные команды

SVNADMIN CREATE - Создать хранилище файлов в SVN

Unix

svnadmin create    /path/to/new/svn/repository

Windows

svnadmin create c:/path/to/new/svn/repository


SVN IMPORT - Первоначальна записать папки с файлами в хранилище файлов в SVN для создания общей структуры проекта

Структура папок вашего проекта должна быть такой.
В папке trunk находятся файлы вашего сайта.
В папке branches находятся ответвления с измененными версиями вашего основного сайта.
В папке tags находятся тэги.



Unix

svn import project file:///path/to/new/svn/repository/project -m "Comment for my First Import"

Windows

svn import project file:///c:/path/to/new/svn/repository/project -m "Comment for my First Import"

Network

svn import porject http://site_name/svn_dir/repository_name/project -m "Comment for my First Import"

Другой пример

svn import myproject  --username jared --password shipit svn://opteron1/svn-repo


SVNSERVE - Запуск SVN сервера

svnserve -d -r c:/path/to/new/svn/repository

Добавление пользователей для подключения к SVN серверу.
В файле svnserve.conf, который расположен в директории вашего проекта (c:/path/to/new/svn/repository) в папке conf, раскомментируйте строки:

[general]
anon-access = read
auth-access = write
password-db = passwd

Все пароли будут хранится в файле passwd, который мы сохраним в этой же папке далее.

Создадим файл passwd и добавим в него следующее содержимое в виде логина и пароля пользователя в формате NAME = PASSWORD:

[users]
jared = shipit


SVN CHECKOUT - Выгрузка файлов из хранилища SVN на локальный компьютер

Unix

svn checkout file:///path/to/new/svn/repository/project/trunk /my/project/local/folder

Windows

svn checkout file:///c:/path/to/new/svn/repository/project/trunk  c:/my/project/local/folder

Network

svn checkout http://site_name/svn_dir/repository_name/project/trunk c:/my/project/local/folder

Другой пример

svn checkout http://192.168.0.54/svn/repos/server_code server_code
svn checkout –username my_username http://192.168.0.54/svn/repos/server_code server_code
svn checkout --username jared --password shipit svn://opteron1/svn-repo

svn checkout -r 1729


SVN LIST - Получить список проектов, находящихся в хранилище SVN

Unix

svn list --verbose file:///path/to/repository/project


Network

svn list --verbose http://site_name/svn_dir/repository_name/project


SVN STATUS - Посмотреть статус внесенных изменений

Unix

svn status

(Сделать обзор всех внесенных изменений)
Например
A stuff/loot/bloo.h # file is scheduled for addition
C stuff/loot/lump.c # file has textual conflicts from an update
D stuff/fish.c # file is scheduled for deletion
M bar.c # the content in bar.c has local modifications


SVN ADD - Пометка файлов и папок для будущего добавления в хранилище в SVN

Unix

svn add file_or_directory_inside_my_project_folder

Для добавления изменений в хранилище SVN необходимо далее выполнить команду svn commit.

Другой пример

svn add my_file.txt
svn add my_folder

SVN DELETE - Пометка файлов и папок для будущего удаления из хранилища SVN

Unix

svn delete file_or_directory_inside_my_project_folder

svn delete my_file.txt
svn delete my_folder

Для добавления изменений в хранилище SVN необходимо далее выполнить команду svn commit.

В отличии от команды add можно удалить файлы напрямую из хранилища SVN.

Network

svn delete -m "Comment Deleting project directory" http://localhost/svn_dir/repository/project_dir


SVN DIFF - Посмотреть (сравнить) внесенные в проект изменения

Показать различия между текущей рабочей директорией и той же директорией в хранилище

svn diff
svn diff my_file.txt
svn diff my_folder


SVN COMMIT - Отправка (добавление) внесенных изменений из локальной папки в хранилище SVN

svn commit -m "Comment Saving recent changes" http://loaclhost/svn_dir/repository/project_dir

Другой пример

svn commit my_file.txt
svn commit my_folder
 

SVN UPDATE - Выгрузка последней версии файлов из хранилища SVN с целью обновления локальных файлов и их замены на файлы из хранилища

Network

svn update

Другой пример

svn update my_file.txt
svn update my_folder

svn update                                    (update from current)
svn update -r BASE server_code (update foo from base revision)
svn update -r 1200 server_code   (update foo from revision number 1200) 


SVN LOG - Посмотреть кто еще переносил свои изменения в хранилище SVN

svn log

Другой пример

svn log my_file.txt
svn log my_folder

svn log -r 8
svn log -r 5:19
svn log -r 19:5


SVN COPY - Тэгирование (копирование) и создание отдельных версий проекта в хранилище SVN

Копирование содержимого директорий

svn copy directory1 directory2

Тэги создают отдельные копии проекта для будущих изменений.
В директори tags создается виртуальная копия проекта.

svn copy http://site_name/repos/project/trunk http://site_name/repos/project/tags/0.1.0 -m "Comment tagging the 0.1.0 release of the project"

Посмотреть список внесенных в проект с тэгом изменений

svn list http://192.168.0.4/svn/repos/prj1/tags/0.1.0/

Выгрузка на локальных компьютер файлов из проекта с тэгом

svn checkout http://192.168.0.4/svn/repos/prj1/tags/0.1.0/


APACHE и SVN - Настройки сервера Apache для создания виртуального хранилища SVN

В файле httpd.conf раскомментируйте следующие строки:

LoadModule dav_module         modules/mod_dav.so
LoadModule dav_svn_module     modules/mod_dav_svn.so

Далее проишите URL-адресе размещения хранилища SVN на сервере:

<Location /svn>
    DAV svn
           
     # All repos subdirs of d:/svn
     SVNParentPath C:/svn
</Location>


TortoiseSVN - Программа для графической работы с SVN

===============================================================

Дополнительные команды

SVN REVERT - Отменить внесенные изменения

svn revert

SVN RESOLVE - Разрешить конфликт файлов

svn update
svn resolve

===============================================================

 SUBVERSION COMMANDS SUMMARY

1.) Checkout the code and do an update in case of any changes made since your last update (We assume that you are using apache dav server to access your code and not svnserve):

    $svn checkout http://192.168.0.54/svn/repos/server_code server_code

If your repository requires authentication:

    $svn checkout –username my_username http://192.168.0.54/svn/repos/server_code server_code

Update your working copy:

    $svn update
    (update from current)
    $svn update -r BASE server_code
    (update foo from base revision)
    $svn update -r 1200 server_code (update foo from revision number 1200)

2.) Make changes:

    $svn add eg svn add new_directory
    (add a new directory foo)
    $svn delete
    $svn copy directory1 directory2
    (copy directory directory1 to directory2)
    $svn move directory2 renamed_directory
    (rename?)

3.) Examine your changes (Can be done even with no network access to the subversion repository):

    $svn status
    (To get an overview of all your changes)
    eg
    A stuff/loot/bloo.h # file is scheduled for addition
    C stuff/loot/lump.c # file has textual conflicts from an update
    D stuff/fish.c # file is scheduled for deletion
    M bar.c # the content in bar.c has local modifications

    $svn diff
    (to show changes between current working directory and the same directory in the repository)

4.) Possibly undo some changes (Can also be done even with no network access to the subversion repository):

    $svn revert
    After running svn revert as a way to resolve local conflict with the repository copy, Run:

    $svn resolve
    To inform svn that the conflict has been resolved. You will now be able to successfully run svn update in case of previous conflicts.

5.) Resolve Conflicts (Merge Others’ Changes):

    $svn update
    $svn resolved

6.) Commit your changes:

    $svn commit
    eg
    $svn commit -m “Removed out of mem errors.”
    or
    $svn commit -F comment.txt
    or
    $svn commit –file comment.txt

6. Logs:

    $svn log (use current working directory as the default target)
    $svn log server_code
    (current working directory/file is server_code)
    $svn log -r 5:19
    (shows logs 5 through 19 in chronological order of working directory)
    $svn log -r 19:5
    (shows logs 5 through 19 in reverse order of working directory)
    $svn log -r 8
    (shows log for revision 8 of working directory)
    $svn log -r 8 -v
    (shows verbose? log for revision 8 of working directory)

7. Diffs (Changes):

    $svn diff
    $svn diff -r 3 rules.txt
    (or svn diff –revision 3 rules.txt)
    $svn diff -r 2:3 rules.txt
    (revisions 2 and 3 are directly compared)
    $svn diff -c 3 rules.txt
    (compare changes between current revision and revision 2)

8. Browse a file directly:

    svn cat -r 2 rules.txt
    svn cat -r 2 rules.txt > rules.txt.v2 (send cat output directly to a file)

9. Browse a folder directly:

    svn list http://svn.collab.net/repos/svn
    svn list -v http://svn.collab.net/repos/svn

10. Fetching older repository snapshots:

    $svn checkout -r 1729
    (Checks out a new working copy at r1729)
    $svn update -r 1729
    (Updates an existing working copy to r1729)

11. If you’re building a release and wish to bundle up your files from Subversion but don’t want those pesky .svn directories in the way, then you can use svn export to create a local copy of all or part of your repository sans .svn directories. As with svn update and svn checkout, you can also pass the – -revision switch to svn export:

    $svn export http://svn.example.com/svn/repos1
    (Exports latest revision)
    $svn export http://svn.example.com/svn/repos1 -r 1729
    (Exports revision r1729)

12. Cleanup if a Subversion operation is interrupted (if the process is killed, or if the machine crashes, for example), the log files remain on disk. By re-executing the log files, Subversion can complete the previously started operation, and your working copy can get itself back into a consistent state.

    $svn cleanup

13. Revision specifiers:
HEAD: The latest (or “youngest”) revision in the repository.
BASE: The revision number of an item in a working copy. If the item has been locally modified, the “BASE version” refers to the way the item appears without those local modifications.
COMMITTED: The most recent revision prior to, or equal to, BASE, in which an item changed.
PREV: The revision immediately before the last revision in which an item changed. Technically, this boils down to COMMITTED-1.

    $svn diff -r PREV:COMMITTED main.c
    (shows the last change committed to main.c)

    $svn log -r HEAD
    (shows log message for the latest repository commit)

    $svn diff -r HEAD
    (compares your working copy with all of its local changes to the latest version of that tree in the repository)

    svn diff -r BASE:HEAD main.c
    (compares the unmodified version of foo.c with the latest version of foo.c in the repository)

    $svn log -r BASE:HEAD
    (shows all commit logs for the current versioned directory since you last updated

    $svn update -r PREV main.c
    (rewinds the last change on foo.c, decreasing foo.c’s working revision)

    $svn diff -r BASE:14 main.c
    (compares the unmodified version of foo.c with the way foo.c looked in revision 14)

14. Checkout based on revisions:

    $svn checkout -r {2006-02-17}
    $svn checkout -r {15:30}
    $svn checkout -r {15:30:00.200000}
    $svn checkout -r {“2006-02-17 15:30″}
    $svn checkout -r {“2006-02-17 15:30 +0230″}
    $svn checkout -r {2006-02-17T15:30}
    $svn checkout -r {2006-02-17T15:30Z}
    $svn checkout -r {2006-02-17T15:30-04:00}
    $svn checkout -r {20060217T1530}
    $svn checkout -r {20060217T1530Z}
    $svn checkout -r {20060217T1530-0500}

15. Logs based on revisions:

    $svn log -r {2006-11-28}
    $svn log -r {2006-11-20}:{2006-11-29}

16. Properties of files:

    $svn propset copyright ‘(c) 2006 Red-Bean Software’ calc/button.c
    property ‘copyright’ set on ‘calc/button.c’

    $svn propset license -F /path/to/LICENSE calc/button.c
    property ‘license’ set on ‘calc/button.c’

    $svn propedit copyright calc/button.c
    No changes to property ‘copyright’ on ‘calc/button.c’

    $svn propset copyright ‘(c) 2006 Red-Bean Software’ calc/*
    property ‘copyright’ set on ‘calc/Makefile’
    property ‘copyright’ set on ‘calc/button.c’
    property ‘copyright’ set on ‘calc/integer.c’

    $svn proplist calc/button.c
    Properties on ‘calc/button.c’:
    copyright
    license

    $svn propget copyright calc/button.c
    (c) 2006 Red-Bean Software

    $svn proplist -v calc/button.c

    $svn propset license ” calc/button.c
    $svn propdel license calc/button.c

    And specify the revision whose property you wish to modify

    $svn propset copyright ‘(c) 2006 Red-Bean Software’ calc/button.c -r11 –revprop

17. Locking files:

    $svn lock banana.jpg -m “Editing file for tomorrow’s release.”
    ‘banana.jpg’ locked by user ‘harry’.

    $svn status
    K banana.jpg

    $svn info banana.jpg
    Path: banana.jpg
    Name: banana.jpg
    URL: http://svn.example.com/repos/project/banana.jpg
    Repository UUID: edb2f264-5ef2-0310-a47a-87b0ce17a8ec
    Revision: 2198
    Node Kind: file
    Schedule: normal
    Last Changed Author: frank
    Last Changed Rev: 1950
    Last Changed Date: 2006-03-15 12:43:04 -0600 (Wed, 15 Mar 2006)
    Text Last Updated: 2006-06-08 19:23:07 -0500 (Thu, 08 Jun 2006)
    Properties Last Updated: 2006-06-08 19:23:07 -0500 (Thu, 08 Jun 2006)
    Checksum: 3b110d3b10638f5d1f4fe0f436a5a2a5
    Lock Token: opaquelocktoken:0c0f600b-88f9-0310-9e48-355b44d4a58e
    Lock Owner: harry
    Lock Created: 2006-06-14 17:20:31 -0500 (Wed, 14 Jun 2006)
    Lock Comment (1 line):
    Editing file for tomorrow’s release.

    $svnadmin lslocks /usr/local/svn/repos
    $svnadmin rmlocks /usr/local/svn/repos /project/raisin.jpg
    Force out someone else’s lock:

    $svn unlock –force http://svn.example.com/repos/project/raisin.jpg
    Force a lock over someone else’s
    $ svn lock –force raisin.jpg

18. Creating branches:

    $svn checkout http://svn.example.com/repos/calc bigwc
    A bigwc/trunk/
    A bigwc/trunk/Makefile
    A bigwc/trunk/integer.c
    A bigwc/trunk/button.c
    A bigwc/branches/
    Checked out revision 340.

Now create the branch;

    $cd bigwc
    $svn copy trunk branches/my-calc-branch
    $svn status
    A + branches/my-calc-branch

    $svn commit -m “Creating a private branch of /calc/trunk.”
    Adding branches/my-calc-branch
    Committed revision 341.

You can do all the above in one step (Recommended way):

    $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.

Merging branch to main trunk (Assuming you are in the working branch directory)

    $svn merge -c 344 http://svn.example.com/repos/calc/trunk (merge change revision number 344 on your working directory branch)
    U integer.c

    $svn status
    M integer.c

Merging while specifying the destination and target:

    $svn merge -c 344 http://svn.example.com/repos/calc/trunk my-calc-branch
    U my-calc-branch/integer.c

    $svn merge http://svn.example.com/repos/branch1@150 \
    http://svn.example.com/repos/branch2@212 \
    my-working-copy

    $svn merge -r 100:200 http://svn.example.com/repos/trunk my-working-copy

    $svn merge -r 100:200 http://svn.example.com/repos/trunk

Previewing merges:

    $svn merge – -dry-run -c 344 http://svn.example.com/repos/calc/trunk
    U integer.c
    (- -dry-run is a double dash without spaces. Word press munges the double dash into one when put together.)

    $svn status
    (nothing printed, working copy is still unchanged)

Merging branch changes into trunk:

    $cd calc/trunk
    $svn update
    At revision 405.

    $svn merge -r 341:405 http://svn.example.com/repos/calc/branches/my-calc-branch
    U integer.c
    U button.c
    U Makefile

    $svn status
    M integer.c
    M button.c
    M Makefile

Examine the diffs, compile, test, etc…

    $svn commit -m “Merged my-calc-branch changes r341:405 into the trunk.”
    Sending integer.c
    Sending button.c
    Sending Makefile
    Transmitting file data …
    Committed revision 406

Undo a merge:

    $svn merge -c -303 http://svn.example.com/repos/calc/trunk
    or
    $svn merge –revision 303:302 http://svn.example.com/repos/calc/trunk
    U integer.c

    $svn status
    M integer.c

    $svn diff
    (Verify that the change is removed)

    $svn commit -m “Undoing change committed in r303.”
    Sending integer.c
    Transmitting file data .
    Committed revision 350.

Merging from branch to trunk:

    $cd trunk-working-copy

    $svn update
    At revision 1910.

    $svn merge http://svn.example.com/repos/calc/trunk@1910 \

    http://svn.example.com/repos/calc/branches/mybranch@1910

    U real.c
    U integer.c
    A newdirectory
    A newdirectory/newfile

Resurrecting deleted items:

    $svn copy -r 807 \
    http://svn.example.com/repos/calc/trunk/real.c ./real.c

    $ svn status
    A + real.c

    $svn commit -m “Resurrected real.c from revision 807, /calc/trunk/real.c.”
    Adding real.c
    Transmitting file data .
    Committed revision 1390.

    Traversing branches:
    $cd calc

    $svn info | grep URL
    URL: http://svn.example.com/repos/calc/trunk

    $svn switch http://svn.example.com/repos/calc/branches/my-calc-branch
    U integer.c
    U button.c
    U Makefile
    Updated to revision 341.

    $svn info | grep URL
    URL: http://svn.example.com/repos/calc/branches/my-calc-branch

    Making releases using tags (snapshot of a directory at a given instant in time)
    $svn copy http://svn.example.com/repos/calc/trunk \
    http://svn.example.com/repos/calc/tags/release-1.0 \
    -m “Tagging the 1.0 release of the ‘calc’ project.”

    Committed revision 351.

    Remove your branch after merge:
    $svn delete http://svn.example.com/repos/calc/branches/my-calc-branch \
    -m “Removing obsolete branch of calc project.”

    Committed revision 375.

    Commit a log message correction:
    $echo “Here is the new, correct log message” > newlog.txt
    $svnadmin setlog myrepos newlog.txt -r 388

    Migrate repository:
    Create the dump files first:
    $svnadmin dump myrepos -r 23 > rev-23.dumpfile
    $svnadmin dump myrepos -r 100:200 > revs-100-200.dumpfile

    Load the dump files into the new repository:
    $svnadmin dump myrepos -r 0:1000 > dumpfile1
    $svnadmin dump myrepos -r 1001:2000 –incremental > dumpfile2
    $svnadmin dump myrepos -r 2001:3000 –incremental > dumpfile3