Svn locally (local Subversion for a single user)
Because the existing top Google results suck, I keep having to waste time whenever I want to do this. [This = setting up a subversion repository in some directory on my filesystem, for use only by myself, so I don't have to worry about remote access and what not.]
What should be the top result is Single-User Subversion on OnLamp.
- Decide a name (e.g. svnrepo) for the directory where the repository (the database etc., not the files) will be stored, go to the directory that will be its parent, and create the directory (and the repo) with: svnadmin create svnrepo.
- Decide a name (e.g. workspace) and location for your workspace (the directory where your files will actually be stored), and create it by checking out the (currently empty) repository into it with svn checkout file:///home/shreevatsa/path/to/svnrepo workspace.
- Go to the directory, create/copy files into it, add them with svn add filename, and commit with svn commit -m "Initial commit".
That’s it. Don’t bother with svn import, svn mkdir etc.
At any time, use
svn status to see what files have changed,
svn diff to see the diffs,
svn log to see history of your commit messages, and
svn update once in a while.
diff and log take arguments like -r 2:20 to mean revisions 2 to 20. HEAD stands for the most recent revision number, so you don’t have to know/remember it.
Just for completeness, my general SVN reference sheet:
==Initial setup (only once)== svn checkout svn+ssh://path/to/repo working-dir ==Work cycle (each time)== svn update # to get the latest version from the repository Now work with your files as you usually would. After you're done, do: svn diff # to see what you have changed svn commit -m "some message, for the history" Extra files you create in the directory are ignored. To add a new file, use: svn add [filename]
Update [2009-10-16]: For git (you can install it on Debian/Ubuntu with sudo apt-get install git-core, and on Mac with this), look here. It’s also very simple. The only counter-intuitive thing is that you apparently need to “add” modified files each time before committing, or use “git commit -a [-m message]“. In detail:
- Create the directory you want to manage, and cd into it. (It can also just be the directory that already contains your files.)
- Do git init. (This creates a .git folder.)
- Add the files you want, with git add FILE
- Commit, with git commit -m "message"
And the workflow each time is to edit files, then git commit -a -m "message" to commit. git status and git diff are self-explanatory. You can do git config --global --add alias.cam "commit -a -m" to be able to just type git cam "message", and git config --global --add diff.color true for colours. (The --global refers to ~/.gitconfig.)