Best way to synchronize my code between multiple workstations? - version-control

Firstly, I'm not sure if this belongs here or programmers. Please move if it needs to be there.
I am mostly a hobbiest web developer, with a bit of freelance sidework. I program anywhere I can, from a laptop on the go to my home PC. I've pretty well settled on Net Beans as my IDE, and xampp for my test environment. My question is how do I best synchronize changes between my different PCs?
I started out FTPing changes to a "dev" area on my webserver, then FTPing them down to my other PC, but that's sort of a pain. Lately I have started using dropbox, which takes a lot of the pain out, but still isn't quite as seemless as I'd like.
Has anyone come up with a bulletproof way to easily ensure you're always opening up the latest version of your files across multiple PCs which aren't necessarily always (but sometimes are) on your home network?
Free is a necessity.

I personally use Subversion.
It integrates easily with Netbeans or Eclipse, and you say you've got a webserver, which I presume is Linux based? It's easy to set up in any Linux environment, though I think it can also be set up in a Windows environment.
Then you just run an update on your code when you want to get the latest version, do checkins when you like it, and you can always go back to earlier code (like if you tried a two day experiment that didn't work out and now want to delete it all and go back to what you had that was working).

Use some version control system. If you are new to this stuff Subversion would be probably the easiest to start with and it is very well intergrated with Netbeans.
You may set up repository on your own server or use some external service - there are a lot of them and almost everyone offers some free plan to start with. I'd be glad to give you some pointers if you like.

Learn to use a version control system.
www.github.com is free for open source projects, but must pay for private source repositories and also closed source projects, hurray.
http://unfuddle.com uses subversion, and is free for 200Mb of private source.
You may find some of the links in this thread useful.

A very simple and efficient way is to open an account on dropbox.com.

I disagree with a lot of the answers here (A lot are pretty old). Git/SVN is not a synchronization solution (nor a backup). It is just a version control system. (But if done correctly you can use git and a sync tool at the same time.)
By using git for synchronization you get the following side effects:
polluted git log: e.g. git commit -am 'synced files'... 'synced files again', 'synced from laptop', 'synced from desktop'
a substandard workflow: every time you leave your workstation or laptop you have to remember to git commit and push. This takes time and mental energy
Instead, I would recommend a solution that offers a continuous sync of your files to a central server. You can close your laptop within five seconds (maybe less) and your changes are propagated to a central server awaiting to sync to other devices when they come online. One priviso: you need to make sure you are not syncing folders like .git so a sync from your laptop .git for your project doesn't corrupt your .git on your desktop. Some options are:
Synology Cloudstation Drive - I can speak personally to this one. It excludes all "." files by default, and syncs at every file change. As soon as you save the file it is synced
NextCloud/OwnCloud - I now use Nextcloud, sync all computers, and make sure to exclude .git so that each git repo will track independent changes against origin BUT still be synced between devices.
Google Drive
Dropbox

You can set up a web-based source repository on something like http://www.github.com, and be able to access it from any computer.

Related

VSCODE remote editing, download-on-open option?

I am mostly editing files remotely in VSCode, and have tried several sftp extensions. ftp-sync has been the best so far, but there is one nagging problem that hopefully someone has solved: Upload-on-save is great and works perfectly, but I'd like to Download-on-open also (with bonus points for warning if the file is different). I sometimes edit the remote files on the remote server, and because there's no check in vscode on open, it's easy to lose those changes. Anyone run into this and have suggestions for a different extension that works this way?
A recent release on March 19th of https://github.com/liximomo/vscode-sftp has added support for this functionality with downloadOnOpen. It works perfectly for my use case (if there's an updated version of the file on the server, download and use that). The UX is a little rough still, but will surely improve over time.
If you're using git locally, there's very little chance of losing local changes, so this works perfectly for the case where you want to edit and manage files locally, but stay in sync per-file with a remote ssh/sftp server.
Look into the Remote VSCode plugin. It doesn't do FTP-like navigation, but if you use SSH, you can tunnel an editing session over the connection into VSCode pretty easily. It felt a little wonky at first, but I use this plugin constantly. As I work across a fleet of a few hundred servers, this option made a lot more sense than trying to set up some of those "deploy" plugins for each host.
Check This Extension on VSCode.Its really awesome.
Remote WorkSpace

How to apply a patch in a remote repository?

Summary:
I created a patch in my local machine, but I need to apply this patch in a remote machine.
I'm using Tortoise in both machines. How can I do this in a proper way ?
Context:
I have development environment in a project that is not very common, I guess. I could develop it in a remote VM, but the Eclipse and the entire machine are so slow that I think is unproductive. Also, I have to use a VPN to connect to the VM, which makes my connection slower. Because of that, I want to develop in my local machine, but, for the build I need to apply this patch in this remote VM to test if the changes were made correctly. I noticed that a patch can't be applied to a unversioned file, for that, I have to clean my entire remote repository with Tortoise and apply the patch again. But I wonder if this is the best approach.
If you are working with two build environments, you have to version ALL of the source files. The only thing that will not be under version control are the build directory and the machine-specific configuration files.
So if a file is not under version control somewhere, it is likely because your project setup is not correct. Take the time put everything in a single folder that can be under version control, start tracking it and then have the two machines communicating with the same repository.
Side note : it is quite common to develop on a machine and build on an other, you should be able to get a simple and efficient work environment quite easily.
I hope I got you question right. If not, please provide more specific info like your project's tree, the reason why you cannot test on your development machine, why is this specific file not under version control and anything else relevant.

Eclipse Auto-Upload on Save, Without Aptana

I'm using Eclipse to develop a website, and I don't want to run Apache, PHP, and MySQL on my local computer. I already have a remote Linux server set up to do that. What I want though, is every time I save a file, Eclipse should upload that file to the Linux server. Dreamweaver does an absolutely perfect job at this task, but I prefer many other features in Eclipse.
I am well aware that there are many, many posts on Stack Overflow about this topic. I have reviewed them, but none seem to quite meet my needs. I'll go through all the possibilities I know about, and talk about why they're not quite right:
Aptana - I specifically excluded this in the question's title. Yes, it does what I'm asking for, but if you install it as an Eclipse plugin, it totally takes over your Eclipse. I only want this one feature, not the whole 800-pound gorilla that changes everything.
Remote System Explorer - I want the primary version to be on my hard drive, not the remote server. This is because I want faster file open, and code completion.
GIT or SVN - When I see other people ask this question on Stack Overflow, someone usually answers "use Git or SVN." Well, I'm already using Git. When I want to sync the entire project, and not just iterate on one file, I will do it using Git. But standalone Git is way too slow if all you want to do is see your changes working. I also don't want to see hundreds of meaningless commits. PTP, mentioned below, is a little better and a little faster, but not fast enough.
PTP - This is an Eclipse plugin that not too many people seem to know about. It has the ability to sync a local folder and a remote folder using Git, and it can do it automatically every time you hit save. This is absolutely awesome, but unfortunately a little slow. When I hit save in Dreamweaver, the change is uploaded to the server in less than one second. The PTP Git operation takes 10 seconds on a tiny project, and I bet that wait gets larger with a larger project. I'm a huge believer in super-fast iteration, and all that PTP waiting will really slow me down.
WebDAV and FTP support for Eclipse - It seems like this is no longer actively developed.
FileSync - Pretty neat, but only supports local filesystem folders.
Are there any other options that I've overlooked? Or are my requirements so specific that there's nothing that fits me right. It seems like there would be other people who want exactly the same thing.
This is my suggestion and it is not quick way to do this, but very customizable.
In eclipse you can set external tools.That means, you can set a php/java script file as external program and send some params that eclipse gives you(${resource_loc} ${project_name} ${resource_path}).
So with script file you can login to SSH or FTP or what ever you want and sync your file or project with remote system.
Just in External Tools Configuration window in eclipse you must set Location to /usr/bin/php
and in Arguments, you can set script path with eclipse variables as script args.
At last you should assign some short key to external program IF Possible.
Did you consider set up Samba server on your Linux and work on you local computer but store project in remote directory served by Samba from Linux or use mentioned FileSync to sync local working directory with network directory (which for Windows look like local and thus FileSync should work).
Or Dropbox?
Edited:
You are constrained heavily I see. Maybe you have on remote host rsync? You could write small utility to manage if your local folder changed (for Windows: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365261(v=vs.85).aspx) and then synchronize folders with rsync via ssh (https://www.digitalocean.com/community/articles/how-to-use-rsync-to-sync-local-and-remote-directories-on-a-vps). This would be completely independent from Eclipse.
you can have a try with CodeSync #github (I write it)
or this one
https://github.com/zhwj184/remotedeploy
Now I am in 2021, and most of the above methods cannot work at all.
Finally, I find a small plugin in Eclipse that is very easy to upload the files (may be not auto-load, but is very easy).
Install the "Alibaba Cloud Toolkit" plugin in Eclipse Marketplace;
Using the right-click "deploy" item to deploy the selected files/directory to the remote directory.
There is also a problem. In my eclipse, the inside Terminal is blank (for all terminals including local terminal and SSH terminal), the blank terminal
But the terminal in RSE is ok.
The terminal in RSE
I also tried to uninstall Alibaba Cloud Toolkit, CDT, TM Terminal, etc.
But the inside terminal does not work anymore.
So I use the terminal in RSE now and put its view, as I just want to run my code on the remote server.

Best option for check-in/out with small team using Visual Studio 2012?

I have a small team of web developers who work together on up to 50 external sites. I am trying to find a better solution to using Dreamweaver's check-in check-out for managing source. We have just started using Visual Studio 2012 here and there and I am curious if TFS is the way to go for us. No one here has ever used versioning or any type of source control before, so I am looking for something similar to what they are used to.
If it matters at all, our sites are all hosted on a Windows 2008 R2 server, and largely written in C#.
I think TFS is a good option to consider. As several people have commented, it will be a jump from what you are your team are used to in Dreamweaver, but I personally feel if you are serious about managing your intellectual property, you will invest in some sort of version control system. With that said, there will be a learning curve regardless whether you are your team select TFS, SVN, Git, etc.
Assuming you do go with TFS, you do get the added benefit of everything else that comes with TFS - it's not just about version control. This includes work item tracking, automated builds/deployments, reports, a simple SharePoint site, etc.
With TFS you get the benefit of all of these features, combined into a single product. You can accomplish a similar setup using open source products as well, but would require you to piece the products together.
I'd use the integrated Subversion client in Dreamweaver, which does the basic stuff very nicely and doesn't require the tedious navigation process that will lead to your team bypassing the system. Only problem, DW does not support the latest versions of SVN so you need to pick up an SVN server that is compatible. Try this:
Setting Up Version Control for Dreamweaver CS6 on Windows
Any previous attempts to get version control working may well have created some .svn folders and files on your PC. You MUST remove ALL of these and UNINSTALL ALL OTHER VARIETIES of Subversion software from your PC before you start.
Go to the VisualSVN Server website and download an archived standard version of their software, version 2.1.16 . Don’t be tempted to grab a later version, because this will install SVN 1.7 or 1.8 and neither will work with Dreamweaver.
http://www.visualsvn.com/server/changes/
Trying to get DW working direct to a local folder using the file:// protocol probably won’t work and is also known to put data at risk. You need the server. I chose to install the VisualSVN server with the default settings, other than opting to use Windows logins and go with HTTP, not HTTPS. I decided to have the repositories live on an internal SSD drive, but any local drive will do. When creating a folder for your repositories to live in, use a name that is pretty general e.g. ourcorepositories . I used lower case for everything.
Right click on ‘Repositories’ to create a new one. Give it a name without any spaces or special characters e.g. mynewprojectrepo and check to ‘Create default structure’ . Before you OK, note the Repository URL and copy it into Notepad or a similar plain text editor so you can refer to it later during 6 below. It will be something like
http://OFFICEDESKTOP/svn/mynewprojectrepo
Notice that the capitalised part of the URL is the name of your computer. Click OK and you now have a repository for your project.
5. Boot DW and go to your project. If you don’t have a project yet, create one and stick some dummy files and folders in it. Go to Site menu>>Manage sites… and 2-click your project. Select Version Control.
6. Set Access to be ‘Subversion’ (no other choices exist), Protocol to be HTTP and for the Server Address enter the name of your computer in lower case e.g.
officedesktop
For the Repository Path enter (e.g., using current example from 4. Above)
/svn/mynewprojectrepo
The Server Port should be 80 . For the Username enter your Windows user name, in lower case. Enter your Windows password for the Password. This is the name and password combo that you use to log in to your PC . Click the Test button and you should get a success message. If not, the best advice is to delete any .svn files and repositories you have created and start again. Be sure not to add any slashes or omit any; the above works. Before you click Save, click the link to the Adobe Subversion resources and bookmark it in your browser. There is a lot of useful background information there. Click Save, click Done.
7. Go to your DW project and open up Local View. All of your site’s files and folders will have a green + sign beside the icon. Right-click on the site folder and click ‘Version control>>Commit” . It is a very good idea to leave comments whenever you change anything, so leave a Commit Message along the lines of “The initial commit for My New Project” and click to Commit. If you have a lot of files to go to the repository, they’ll take some time to upload. As they upload, the green + signs disappear to show that you local version is in synch with the repo.
8. Okay, that’s it, you have Version Control in Dreamweaver CS6. It may also work in CS5 and 5.5. Check out those Adobe resources for some good insights on workflow. I can’t help with any other ways to implement version control, but I can maybe save you time by saying that DW doesn’t integrate with Git and that the basic, but integrated, Subversion client in Dreamweaver is way better than having no version control. For coverage against physical disaster, I’d also add in a scheduled daily backup of your entire repositories folder to some cloud storage.
Apologies for any errors. I’d recheck all of the steps, but A) I think they’ll get you up and running and B) it’s easier to do the install and set up the first time than the second time (all those .svn files and folders to get rid of).

How can I utilize source control when my working copy needs to be on a shared host without SSH access?

I'm trying to develop a little toy PHP project, and the most convenient location to run it is on a shared host I happen to have for my ill-maintained blog. The problem with this is that I have no way to run Subversion on this shared host, nor do I even have SSH access to be able to access an external repository from the host. Had I been thinking straight a few months ago when the hosting was up for renewal, I probably should have paid a couple extra bucks to switch to something a bit better, but for now I can't justify throwing money at having a second host just for side projects.
This means that a working copy of my project would need to be checked out to my laptop, while the project itself would need to be uploaded to the shared host to run. My best option seems to be creating a virtual machine running Linux and developing everything from in there, but I know from past experience that the extra barrier that creates, small though it may be, is enough that it puts me off firing the VM up just to do a couple minutes work to make some minor change I just thought up. I'd much prefer to just be able to fire up my editor and get to work.
While I'd imagine I'm not the first to encounter such a problem, I haven't had much success finding a solution online. Perhaps there isn't one beyond the VM or "manual mirroring" options, but if there is I'd expect StackOverflow to be the place to find it.
Edit: There's some confusion, it seems, so let me attempt to clarify. The shared host here is basically my dev server, but it has no svn or ssh. In other words, I can svn checkout to my laptop, but I can't run that on my shared host. Similarly, I can run/test my code on the shared host, but I can't do that on my laptop (well, I technically could, but it's Windows, and I don't want to worry about Win-vs.-Linux differences with PHP, since I do want this to become public at some point, and it will certainly be Linux-based at that point).
You might consider writing a post-commit hook to automatically upload the code to your host, so that any time you commit a change, a script executes that:
Checks out a copy of the code into a temporary directory
Uploads that code via FTP (or whatever your preferred method is) to the shared host
Cleans up after itself, optionally informing you via e.g. email when the transfer is successful
Subversion makes enough information available to these scripts at runtime that you could get more sophisticated and opt only to upload the files that changed or alter behavior based on specific property changes, for instance, but for a small project the brute force "copy it all" approach should be fine.