Git Archive Master vs Subversion Export

I have been using Subversion for years. Often, I refer to Subversion commands when I have questions with Git. Subversion has an “export” command when you want a copy of the repository without the .svn directories and files. The question is, does Git have an “export” function similar to Subversion? The answer is yes. It’s called “archive master.”

To export in Git, go to the root of your Git project. For example:

$ cd ~/git/project

Create a gzip file or a zip file.

$ git archive master | gzip > project.tgz

or

$ git archive master | zip > project.zip

That’s it. You now a have a compressed copy of your project.

Install Git On Your Ubuntu Desktop

I’ve been using Subversion for years. Git has been picking up a lot of steam. So, it’s time for a version control refresh. I’ve been playing around with Git the last three weeks. I love it. If you’re interested in learning Git, or just want Git installed on your Ubuntu desktop, this is an article for you. For weeks, I have been looking for a really easy way to install Git, but I haven’t seen one to my liking, until tonight when I found this website.

I found this Git package that is ready for all the latest Ubuntu releases. It’s available for Ubuntu 10.04 LTS, which I am using at the moment, and all the way to the latest release, version 11.04. All you have to do is add the repository to your software source. To install Git, open up your Terminal and type in the following commands:

Add Repository

sudo add-apt-repository ppa:pdoes/ppa/ubuntu

Update

sudo apt-get update

Install Git

sudo apt-get install git

If you’re new to Git, start learning by reading the Git Tutorial online. It’s excellent documentation by the way. So, there you have it. An easy way to install Git on your Ubuntu desktop.

Creating Subversion Tags in Ubuntu

I just ran into an issue while creating tags in Subversion. I was using the example given from the documentation how to create Tags.

The example command given is:

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

Unfortunately, this command spits out an error saying:
svn: Cannot mix repository and working copy sources

Here’s the fix:

Removing the backslash seem to do the trick. Anyways, I’m not sure if the Subversion instructions need to be updated to reflect this finding, or if this command only works in Ubuntu, or just on my system. Nevertheless, it’s one way of creating Subversion Tags in Ubuntu.

Upgrade WordPress Using Subversion and Shell Script

Every couple of months or so, a new version of WordPress comes out. If you own a dozen blogs in your arsenal, you will need to upgrade each one of them. Thankfully, there is the automatic upgrade button available within WordPress. But still, you still have to login to each one of them and click on each button to upgrade WordPress. You wish there was an easy way to upgrade all 20 blogs with a single command.

Well, there is a simple solution with the help of Subversion and Shell Script. For several years, I have been using Subversion to upgrade WordPress. Each time there is a new version of WordPress, I just type in a single command to upgrade a dozen blogs or so. For the most part, it takes less than 30 seconds to upgrade a dozen of blogs.

Here is the simple Shell Script:

#!/bin/sh
# A script to upgrade dozens of WordPress installs using Subversion.
 
wpv=http://svn.automattic.com/wordpress/tags/2.9.2
 
echo “Upgrading blog 1cd /home/user/blog1.com/
svn switch $wpv
 
echo “Upgrading blog2.com”
cd /home/user/blog2.com/
svn switch $wpv
 
echo “Upgrading blog3.com”
cd /home/user/blog3.com/
svn switch $wpv

and so on….

If you have 20 blogs or so, you will need to include all 20 of them in one little script. You just need to change the “wpv” variable to point to the latest WordPress version. Once you made the change, and depending on the amount of files that has changed from one version to the next, the upgrade process can take anywhere from 10-30 seconds — that’s for 20 blogs!

For this script to work, you will need access to a web server that supports both Subversion and SSH. First, you need to install WordPress using Subversion. That can be easily done using the Subversion Checkout command. Once installed, you can create a simple Shell script like the one above, to execute the upgrade process. If your web host supports both, you might want to consider this little script when upgrading WordPress.

WebDav and Ubuntu Encrypted Home Folder

I’ve been struggling in getting WedDav to work with my Subversion repository that’s installed on my home folder.  The problem lies with the way Ubuntu 9.10 encrypts the home folder. There seems to be no way around to the permission issues with WedDav. There are two things you can do: you can move your repository outside your home folder, or choose not to encrypt your home folder when installing Ubuntu. Anyways, encrypting your home folder is a nice feature, but it also brings some potential issues.

Install Subversion Repository on Ubuntu Desktop

This is a tutorial how to install a Subversion on your desktop. Subversion is an open-source revision control system. A repository is usually installed on servers so developers and programmers can have easy access to code. Subversion uses a check-in an check-out process for submitting changes to the repository. The repository can also be installed on desktop systems. Access is gained through many means by way of direct file access, ftp, http, svn and svn+ssh. See chart below.

Installing Subversion will install both Subversion administration tools and the client. In Ubuntu or Debian-based systems, you can install Subversion by performing the following commands. By the way, I added an Apache and Subversion WebDav module so both can be installed with just a single command.

Install Subversion

sudo apt-get install subversion libapache2-svn

Reboot the Apache Web Server

sudo /etc/init.d/apache2 restart

Create a Subversion Repository

svnadmin create /home/yourname/repository/

I’m placing the repository in my home directory. You can place it anywhere in your system. You may need to use sudo if you install it outside of your home directory. Remember the repository location, we will use it a few times below to configure the Apache Subversion WebDav module, etc.

Import your Repository

svn import /path/to/import/directory file:///home/yourname/repository

If you have a repository ready, now is a good time to import it. If you are just starting out, you can initialize the Repository here.

Access to Subversion

file:// Direct access on local disk
http:// Browser using http WebDav protocol
https:// Browser using https secure and WebDav
svn:// Subversion protocol
svn+ssh:// Subversion protocol and SSH tunnel

Configure WebDav protocol

sudo vi /etc/apache2/apache2.conf

Add

<Location /svn>
DAV svn
SVNPath /home/yourname/repository
AuthType Basic
AuthName "Repository"
AuthUserFile /etc/subversion/passwd
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>

Change Ownership to HTTP-User

sudo chown -R www-data:www-data /home/yourname/repository

Password Protect the Repository

sudo htpasswd -c /etc/subversion/passwd username

You will be asked to provide a password. Enter the password twice.

Reboot Apache Server

sudo /etc/init.d/apache2 restart

It’s probably a good idea to restart the Apache server one more time.

Browser Access
Next, open up your browser and access http://localhost/svn from the address bar. You will be asked for the username and password. You should see the repository and any content or directory underneath it. That’s it. Happy coding.

Automatic Upgrade and Subversion

I have been using Subversion to manage WordPress upgrades for two years now. When WordPress 2.7 appeared, it came with an Automatic Upgrade feature that made one click upgrade possible. Unfortunately, for those of us who have been using Subversion to switch from one WordPress version to another, the Automatic Upgrade feature breaks Subversion. The .svn directories that are essential for tracking and version control are no longer available.

But, I am happy to say the WordPress upgrade went without a hitch. The WordPress 2.8 files were installed and the database upgrade worked as well. This means only one thing: Automatic Upgrade and Subversion can’t co-exist. You either have to use one or the other. Although nothing could be easier than a one click upgrade, I still feel comfortable using Subversion when upgrading WordPress. Maybe, it’s because I know exactly what happens inside the Subversion upgrade.

In addition, I also have multiple blogs to upgrade each time a new WordPress version comes out. To make life easier, I run a small shell script to upgrade all of my WordPress instances at once. Here’s a sample of the shell script below:

#!/bin/sh

# A script to upgrade several WordPress instances using Subversion.

wpv=http://svn.automattic.com/wordpress/tags/2.8 
 
echo "Upgrading domain.com"
cd /home/user/domain.com/
svn switch $wpv
 
echo "Upgrading domain2.com"
cd /home/user/domain2.com/
svn switch $wpv

As you can see, the shell script is quite simple. I just have to make one minor change to the script every time an upgrade is needed, and that is, to assign the latest tag to the $wpv variable.

Subversion List of Commands

To some of us who use Subversion occasionally, I documented several of the popular commands that I use quite regularly at http://subversion.surfcali.com. Subversion is version control system that I use for keeping track of my programming projects. Documentation is available online, but I’ve made a short list of popular commands that are much simpler to read. It works as a great online reference tool as well.

So, here’s my handy list of Subversion commands.

Keeping Up With WordPress Development

One way of keeping up with the latest WordPress development is to install WordPress using Subversion. Subversion is an open source version control system. Using Subversion is a great way of synchronizing your WordPress install with the latest code changes in WordPress development.

In this example, we will install WordPress files in the /var/www/wordpress directory using the Subversion checkout. We will get the latest WordPress development code in the main WordPress “trunk” at Automattic’s. To install WordPress using Subversion:

cd /var/www/wordpress
sudo svn co http://svn.automattic.com/wordpress/trunk .

At this moment, there’s a big redesign of the WordPress’ Dashboard. The design changes will be part of the WordPress 2.7 release. The Dashboard changes are significant. The redesign employs a new menu system with an entirely different look and feel.

To keep up with daily development, I’ve installed a WordPress instance using Subversion. Updates to my install with the main development track called “trunk” can be synchronized in seconds using a simple command line entry (see below).

# sudo svn update

Having a WordPress instance maintained by Subversion is key to keeping up with the latest WordPress development. It’s a great way of familiarizing oneself to the upcoming WordPress release before it hits the general public.

You can also participate in the testing and bug reporting. The WordPress community can always use a few more users to test the greatest and latest code.

SubVersion Basic Commands

I started using Subversion for a web programming project. Just sharing a typical work cycle when using Subversion. For an in-depth look at each command, just visit Subversion’s documentation online.

Updating your working copy:

svn update

Making changes:

svn add, svn delete, svn copy, svn move

Examining your changes:

svn status, svn diff

Undoing changes:

svn revert

Resolving Conflicts (Merging):

svn update, svn resolved

Committing your changes:

svn commit