This hopefully will help those not familiar with source control systems and command prompts, specifically Cygwin tools and Subversion, get up to speed on what they are and how you use them. This won’t explain how to setup Subversion Source Control, but rather how to use tools to connect to it for a project. This article assumes you already have Subversion on a server somewhere with a project already checked and waiting to be worked on by developers.
I made this tutorial because I had no idea what Subversion was, no idea what Cygwin is or does, and no idea how to connect to the Subversion server remotely without a GUI (even with). I’ve included a list of common commands at the bottom of the Cygwin part; I kept forgetting them so am documenting them here (yes, they are in the manual, duh but’s easier to type in my website, and search vs. digging in my filesystem).
I’ve also inclued a brief on using TortoiseSVN, the GUI way of doing things.
If you are proficient in these technologies, please feel free (in fact, I encourage you) to add corrects, modifications, and suggestions in the comments of this entry.
For those of you not from a server-side, IT, admin, or hardcore programming background, you might feel intimidated and confused about what Subversion is, why you need it, and how to set it up.
Skip to “Getting Started” if you want to know how to get setup.
My Background & Take on Subversion
The more I get integrated into becoming a true programmer, and fade farther and farther away from the world of design (my last tether using Flash to make a living), the more I learn about tools that normal developers use in their day to day lives, and just “know” all the nuances that are involved in setup and using them.
I know jack, and it’s extremely intimidating and frustrating to ease into it. For example, it was easy for me to get into PHP; I knew Lingo, ActionScript, and had done enough HTML + CSS & ASP in my career to get the gist of how PHP worked.
Getting into Subversion, though, is a whole other ballgame.
I have worked at a company where the code base was just over a year old and we used Visual Source Safe for botht the .NET back end and the Flash front-end. At the time, I could see the benefit. However, most of my background is in 2 week to 2 month projects, working at breakneck speed, and that’s the last you see of them once they get out the door. When you do make changes, they are last minute, hard to do, and usually not what you wanted to do.
When given other people’s code, I typically just re-write it since the track record of maintainable & portable code written in the Flash professional world, in my experience, is not there yet because of the debate on best practices and the wide array of approaching solutions to problems. Therefore, source safe solutions have always seemed silly to me; why check something in when your done, and you’ll just re-do it. If you made a change last week that broke something you did now, there is no point in going back since the code base has probably changed significantly since then.
That attitude has changed since I’ve worked on bigger projects, and worked with “others”. Typically, I’ve been the sole Flash guy, or sole programmer, so never had to interact with others or a community code based like open source software. Now I have, and do, and recognize why source control systems are in place.
But, Subversion? Unlike Visual Source Safe, it’s free. Unlike CVS, it… well, to me, makes sense. I never understood the WinCVS GUI, and was glad BellSouth never got it working for me. It appeared to have the same user friendliness as Lotus Notes.
I’ve also heard Subversion can be made more secure using SSH (secure way of accessing stuff over the interweb… er, net).
Regardless, I know my company uses it, and I need to get comfortable using it with the other developers (Flash, PHP, Java, etc.).
Getting Started – How do I use it?
There are 2 ways that I know; I haven’t figured out how to get JSFL and bat files to allow you to do it in the Flash Project Panel yet. If you don’t know what that is, it is the Panel in Flash that, like Dreamweaver’s Files panel, allows you to see all of the files related to your Flash project. It’s folder structure doesn’t have to match your actual folder structure (although I make sure to do so). The benefit at BellSouth was I could easily right click on an AS file, and check out the file. It would take 10 years, but it would work with Visual Source Safe. In the past, I had to close the file, toggle to Visual Source Safe, and do my file operations of chekin/checkout there, then toggle back to Flash.
The first way is to use a bash shell (I think that’s what it’s called). Basically, it’s one of those command windows, the black ones you see sometimes that do weird stuff. I’ve found this is quick and easy once you get used to it. Imagine instead of launching Dreamweaver, waiting, and then connecting to your FTP server, you could just ftp a file by typing 2 lines within 10 seconds? That is one benefit I’ve found.
The one I’ve been using is called Cygwin; it’s a bash shell for Windows. It installs 10 billion things, and you don’t need them all. You can get it here:
What it really is a setup.exe file that connects and lets you install the components over the internet. For now, all you really need to ensure you have is:
When presented with the list, which starts with “All” and then shows “Admin”, etc. down a list, those are lists of components you can install with it. Under base, if you select “cygwin”, it’ll automatically select most of the other files you need. However, manually ensure you get the 2 mentioned above. Clicking on the pluses “+” or words will show the list of files underneath the category. Click the circlar arrows icon will toggle how the category installs. It should be “default”.
All > Base > cygwin
All > Devel > subversion
All > Libs > openssl
All > Net > openssh
All > Net > openssl
“But Jesse, some of the things listed the user does not need.”
Dude, trust me, if I install all of that stuff, I can successfully connect to my subversion server at work from home, and check in/check out files. If you know of exactly what files the user needs, please leave a comment to this entry.
Here are some commands to get you at least something to start with.
To navigate to other directories (use forward slash for folders and a backslash in front of spaces in folder and filenames):
To check files out to a directory:
svn checkout svn+ssh://yoursubversionserver ProjectName
To check in files:
svn commit folder\filename -m “I changed the algorithm”
What has changed:
svn status filename
What is different about my file and the file checked in:
svn diff folder\filename
Get the latest files that are checked in:
TortoiseSVN: Command Line? Screw that mess!
No problem, I’m tentative about learning a command line interface too because it doesn’t integrate with my usual workflow. There is a GUI, called TortoiseSVN, you can use that intergrates with Explorer, like Winzip does. It’s cool; it shows the checked out files with different icons, and is all accessible with right click.
However, I still recommend installing all that weird stuff above becuase:
– it’s easier for your IT admin to help you debug problems when you have a shell to test commands
– it installs the necessarey files needed to connect anyway, and TortoiseSVN needs an SSH program anyway
You can get Tortoise SVN here:
And after you install, and do the mandatory reboot:
– right click inside the folder your gonna put your Flash/Flex/PHP project, and go to “TortoiseSVN > Settings…”.
– Click on the “Network” Tab
– in the bottom field, SSH client, navigate to something like: “C:\cygwin\bin\ssh.exe”
If you don’t see that filepath, re-run the setup.exe for Cygwin, and look for more ssh type files in the huge list and make sure they are installed. Then, try finding it again.
After hitting ok, you should be able to log into your server.
I couldn’t connect initially because my server admin at the office had to have me do 2 things:
1. Change my host file to say our server’s name.
Basically, if you type in an acronym for your server’s names, like “enterprise”, you do this because it’s easier to remember than 22.214.171.124 or that’s what the box is really named. Obviously, your computer doesn’t know where “enterprise” is. Your computer probably DOES know where yahoo.com is; but that’s because of Internet nameservers that go “Yo, dude, Yahoo’s this way…”. For personal stuff, you’ll have to input the exact static IP address, or “exact internet address”.
You can do this by modifying your host file. I recommend a backup just in case you fubar something.
Mine is here:
Notice, it has no file extension. Just open it in Notepad; I usually drag and drop it.
For my server at work (which we don’t really have an enterprise, but let’s just say we do):
Save the file, and close Notepad. You’ll know it worked if you can open Firefox or IE and type in “enterprise” into the address bar, and hit the server. Whether the admin actually has anything runnig, such as a webserver to show you anything is a different story, so just because you get a 404 doesn’t mean that it didn’t work; it could just be ignoring web traffic.
Who I am and who my box thinks I am
The second thing is how SSH clients store security information and transmit who they are to the server. Without getting technical about stuff I have no clue about, here’s what I had to do:
Cygwin, the bash shell black window thing, wouldn’t connect to the server when I typed in the commands my admin gave me. That’s because the server admin had setup a username and password for me called:
However, Cygwin was using my WindowsXP username, like “Cow”. So, when I tried to check files out or log into my ftp account, it wouldn’t work, even with the correct password.
SO, I had to manually edit the file that Cygwin uses to talk identify to the server who is talking to it.
Mine was here:
Make sure to make a backup.
Basically, open it up in Notepad, and anywhere you see your Windows login name, change it to whatever the username your admin gives you. Save the file, and restart Cygwin, or try again using TortoiseSVN.
Typically, you check out files, edit them (you’ll see a “!” with Tortoise), and save them. Then, you do an update in Cygwin, or Tortoise to ensure you have the lastest, and commit or “check in” the files you’ve changed. You usually ensure that you have the lastest files first so you don’t overwrite someone’s changes, AND you should always leave a comment of what you did and changed. If someone else has changed the file your working on, the general rule of thumb is the last person has to merge their changes with the existing code.