Richard Riley's web site (inprogress)
DVC: Distributed Version Control for Emacs - a tutorial for the GIT user
A short practical introduction to using DVC for the GIT user. It is recommended that the new user works his way through the tutorial.
Table of Contents
Introduction
This short GIT tutorial is intended as users introduction to using DVC with GIT and is aimed very much for the beginner . The TLA focus in the official info files is not always applicable to GIT. This brief tutorial focuses on a local repository and aims to instruct the DVC beginner on how to use it to interface to a GIT repository for the standard CVS/RCS tasks of
- Repository creation
- Version management
- Difference tracking
It covers repository creation, file creation and registering as well as standard difference management.
See the following link for recommended GIT and DVC links:
- DVC and GIT links : http://richardriley.net/projects/emacs/git/index.html
Pending Inclusion
New Commands
Command List
-
Command are available using C-x V o and then:
- c create branch
- s switch to branch
- l list available branches
- xgit-branch : Create a new branch in the current project.
- xgit-checkout : Switch to another branch in the current project
- xgit-branch-list : List available branches in the current project
Issues
NOTE : fixed on 5th November, pending testing.
For the xgit-checkout to work properly one must currently initialise ido-mode to 'buffer properly before loading dvc. Normal completing-read does not work on my set up (4 Nov 2008) for some reason. Setting up ido-mode after loading dvc does not work either (sent email to Stefan about this).
So for the sake of it working I currently have
(ido-mode 'buffer) (load-file (expand-file-name "~/.emacs.d/dvc/dvc-load.el"))
in my programming.el and later on in my .emacs I have normal ido mode init and ffap init:
(require 'ido) (setq ido-enable-flex-matching t) (ido-mode 'buffer) (ffap-bindings)
Installation of DVC
Getting DVC
DVC can be downloaded from the links listed at http://www.xsteve.at/prg/emacsdvc/dvc.html
Installation
You need to generate a configure file before you can make DVC. Read instructions in the INSTALL file, but I found the following to be sufficient for my needs:
cd /path/to/dvc autoconf make
Then add the location of the newly created load definitions file to your .emacs:
(load-file "/path/to/dvc/dvc-load.el")
Evaluate this form or restart emacs as you wish.
Initialising your GIT repository
Create yourself a tutorial directory - mine will be ~/git-tutorial
mkdir ~/git-tutorial cd ~/git-tutorial
We will now initialise the GIT repository. I do this from the command line as follows:
shamrock@development:~/git-tutorial$ git init Initialized empty Git repository in /home/shamrock/git-tutorial/.git/
Create two files, f1 and f2, in your git-tutorial directory. I used the touch command on my linux system:
touch f1 f2
These files exist but are currently not stored in the repository. We will now see how to do that using the Emacs DVC interface.
Relevant links
- Basic GIT Repository Commands : http://www.kernel.org/pub/software/scm/git/docs/everyday.html#Basic%20Repository
Using DVC to manage a project
DVC Bookmarks
Most programmers will have multiple repositories. Possibly even using different back ends. In this tutorial we assume the GIT backend but it's not necessarily relevant. We use DVC bookmarks to select the repository we wish to work with.
Populate the repository with new files
In the last section, note the lines for our newly created files, f1 and f2. The "unknown" informs us that DVC knows nothing about them. Lets fix that by adding them. We do this by pressing a having first marked them with m
a runs the command dvc-add-files, which is an interactive compiled Lisp function in `dvc-unified.el'.
or, alternatively, add them all with A
A runs the command xgit-status-add-u, which is an interactive compiled | Lisp function in `xgit.el'. |
Refresh the status buffer with g
g runs the command dvc-generic-refresh, which is an interactive compiled Lisp function in `dvc-utils.el'.
We can now see out two newly added files:
git status for /home/shamrock/git-tutorial/
added f1
added f2
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: f1
# new file: f2
#
These changes are not committed. They are merely staged. Should you wish you could undo this by resetting the GIT Index from the menu using
<menu-bar> <GIT-Diff> <Reset index (reset --mixed)> runs the command xgit-status-reset-mixed, which is an interactive compiled Lisp function in `xgit.el'. It is bound to <menu-bar> <GIT-Diff> <Reset index (reset --mixed)>. (xgit-status-reset-mixed)
But we wish to work with these staged files and so we will commit them. The standard commit will commit all work in the current staging area. We commit our files to the repository using c from the status buffer:
c runs the command dvc-log-edit, which is an interactive compiled Lisp function in `dvc-unified.el'.
We add a note, hit C-c C-c to save the commit note and then refresh the status buffer using g once again.
git status for /home/shamrock/git-tutorial/ # On branch master nothing to commit (working directory clean)
Opening files and modifying them - using diff in DVC and more commits.
Open your status using C-x V s, select your bookmark. Now open f1 using the normal open file command C-x C-f
Lets modify f1 : add the text R1. Save it.
Now we can see the differences between modified files and the committed ones. Hit C-x V = while in the file f1.
C-x V = runs the command dvc-diff, which is an interactive compiled Lisp function in `dvc-unified.el'.
Select "y" when prompted to use the index.
A diff buffer appears:
diff --git a/f1 b/f1 index e69de29..1e1244e 100644 --- a/f1 +++ b/f1 @@ -0,0 +1 @@ +R1
We can see the difference between our working copy and the committed original. Note that this shows ALL differences in all files in the project. Should you just want to see the difference in ONE file then highlight it in the status buffer and hit =
= runs the command dvc-diff-diff, which is an interactive compiled Lisp function in `dvc-diff.el'. It is bound to =, <menu-bar> <DVC-Diff> <File Changes> <View Diff in Separate Buffer>.
But what about the project status? We can jump direct to the status using C-x V s
C-x V s runs the command dvc-status, which is an interactive compiled Lisp function in `dvc-unified.el'.
or, we can go back to the bookmark UI, highlight the project we are interested in and hit s.
git status for /home/shamrock/git-tutorial/
modified f1
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
#
# modified: f1
#
no changes added to commit (use "git add" and/or "git commit -a")
If we wish to commit these stages we first need to stage them using A or a from the status buffer and then commit them using c as described in an earlier section.
Using ediff with DVC
We can diff on an individual file using diff = OR ediff should we so please by hitting e
e runs the command dvc-diff-ediff, which is an interactive compiled Lisp function in `dvc-diff.el'.
Date: 2009-12-08 17:33:40 CET
HTML generated by org-mode 6.33trans in emacs 23
