For my school work, I do a lot of switching computers (from labs to my laptop to the library). I'd kind of like to put this code under some kind of version control. Of course the problem is that I can't always install additional software on the computers I use. Is there any kind of version control system that I can keep on a thumb drive? I have a 2GB drive to put this on, but I can get a bigger one if necessary.
The projects I'm doing aren't especially big FYI.
EDIT: This needs to work under windows.
EDIT II: Bazaar ended up being what I chose. It's even better if you go with TortoiseBzr.
I do this with Git. Simply, create a Git repository of your directory:
git-init
git add .
git commit -m "Done"
Insert the stick, cd to directory on it (I have a big ext2 file I mount with -o loop), and do:
git-clone --bare /path/to/my/dir
Then, I take the stick to other computer (home, etc.). I can work directly on stick, or clone once again. Go to some dir on the hard disk and:
git-clone /path/to/stick/repos
When I'm done with changes, I do 'git push' back to stick, and when I'm back at work, I 'git push' once again to move the changes from stick to work computer. Once you set this up, you can use 'git pull' to fetch the changes only (you don't need to clone anymore, just the first time) and 'git push' to push the changes the other way.
The beauty of this is that you can see all the changes with 'git log' and even keep some unrelated work in sync when it changes at both places in the meantime.
If you don't like the command line, you can use graphical tools like gitk and git-gui.
Darcs is great for this purpose.
I can't vouch for other platforms,
but on Windows it's just a single
executable file which you could keep
on the drive.
Most importantly, its interactive
command line interface is fantastic
and very quickly becomes intuitive
(I now really miss interactive
commits in any VCS which lacks them) - you
don't need to memorise many commands as
part of your normal workflow either. This
is the main reason I use it over git for
personal projects.
Setting up:
darcs init
darcs add -r *
darcs record -am "Initial commit"
Creating a repository on your lab machine:
darcs get E:\path\to\repos
Checking what you've changed:
darcs whatsnew # Show all changed hunks of code
darcs whatsnew -ls # List all modified & new files
Interactively creating a new patch from your changes:
darcs record
Interactively pushing patches to the repository on the drive:
darcs push
It's known to be slow for large projects, but I've never had any performance issues with the small to medium personal projects I've used it on.
Since there's no installation required you could even leave out the drive and just grab the darcs binary from the web - if I've forgotten my drive, I pull a copy of the repository I want to work on from the mirror I keep on my webspace, then create and email patches to myself as files:
darcs get http://example.com/repos/forum/
# Make changes and record patches
darcs send -o C:\changes.patch
You could use Portable Python and Bazaar (Bazaar is a Python app). I like to use Bazaar for my own personal projects because of its extreme simplicity. Plus, it can be portable because Python can be portable. You will just need to install it's dependencies in your Portable Python installation as well.
The best answer for you is some sort of DVCS (popular ones being Git, Mercurial, Darcs, Bazaar...). The reason is that you have a full copy of the whole repository on any machine you are using. I haven't used these systems personally, so others will be best at recommending a DVCS with a small footprint and good cross platform compatibility.
I'd use git. Git repos are really small and don't require a daemon. You can probably install cygwin or msysgit on your flashdrive.
Edit: here are some instructions for installing cygwin on a flash drive
Just to add an extra resource Subversion on a Stick. I've just set this up on my 4GB USB Drive, pretty simple and painless.
Thought I am now very tempted to try Bazaar.
Update: I've setup PortablePython on my USB drive, simple, but getting bazaar on there ...
I gave up, one dependency after another, and as I've got svn working.
If anyone knows of an easy portable installer, I'd be greatful.
I recommend Fossil http://www.fossil-scm.org/
includes
command line
dvcs
cross platform (and easy to compile)
'autosync' command make the essential task of syncing to a backup easy.
backup server configuration is a doddle.
easy to learn/use
very helpful community
web ui with wiki and bugtracker included.
3.5Mb, single executable
one sqlite database as the repository
You could put the subversion binaries on there - they're only 16ish megs, so you'll have plenty of room for some repositories too. You can use the official binaries from the command line, or point a graphical tool (like TortoiseSVN) to the repository directory. If you're feeling fancy then you could rig the drive to autorun the SVNSERVE application, making any computer into a lightweight subversion server the minute you plug in the drive.
I found some instructions for this process here.
I use subversion on my thumb drive, the official binaries will work right off the drive. The problem with this trick is you need to access a command line for this to work or be able to run batch files. Of course, I sync the files on my thumb drive to a server that I pay for. You could always host the repository on a desktop (use the file:/// protocol) if you don't want to get hosting space on the web.
I will get lynched for saying this answer, but it works under Windows: RCS.
You simply make an RCS directory in each of the directories with your code. When time comes to check things in, ci -u $FILE. (Binary files also require you to run rcs -i -kb $FILE before the first checkin.)
Inside the RCS directory are a bunch of ,v files, which are compatible with CVS, should you wish to "upgrade" to that one day (and from there to any of the other VCS systems other posters mentioned). :-)
Subversion would kinda work. See thread
Personally, I prefer to keep everything on a single machine and Remote Desktop into it.
Flash memory and version control doesn't seem like a good idea to my ears. I'm afraid that the memory will wear out pretty soon, especially if you take extensive use of various version control operations that make many small disk operations (merge, reverting to and fro, etc).
At the very least, make sure that you back up the repository as often as humanly possible, in case the drive would fail.
I'm using GIT according to Milan Babuškov's answer:
(1) create repository and commit (on office PC)
mkdir /home/yoda/project && cd /home/yoda/project
git init
git add .
git commit -m "Done"
(2) insert USB stick and make a clone of the repository
cat /proc/partitions
mount -t ext3 /dev/sdc1 /mnt/usb
git clone --bare /home/yoda/project /mnt/usb/project
(3) take the USB stick home and make a clone of repository at home
cat /proc/partitions
mount -t ext3 /dev/sdc1 /mnt/usb
git clone /mnt/usb/project /home/yoda/project
(4) push commits from home PC back to USB stick
mount -t ext3 /dev/sdc1 /mnt/usb
cd /home/yoda/project
git push
(5) take USB stick to the office and push commits from stick to office PC
mount -t ext3 /dev/sdc1 /mnt/usb
cd /mnt/usb/project
git push
(6) pull commits from office PC to USB stick
mount -t ext3 /dev/sdc1 /mnt/usb
cd /mnt/usb/project
git pull
(7) pull commits from USB stick to home PC
mount -t ext3 /dev/sdc1 /mnt/usb
cd /home/yoda/project
git pull
bitnami stack subversion it's easy to install.
You can try to install so too xampp with portableapps.com and subversion.
Related
My network from work doesn't let me clone any repository via Windows Git tool by command line git clone therefore I just download the repository.
My problem now is, I need to checkout by git checkout ###### but I cannot figure out how I can do that on my Windows 7. I have installed GitBash tool and Git Desktop, but as I said my network doesn't allow me to do much.
Option 1: local clone
Making a local clone should be your easiest option: it does not involve clone anything from the web so your administrator rules might allow it.
I'll assume you downloaded the remote into workspace/downloaded-bare.git:
cd workspace
git clone downloaded-bare.git sandbox
now you should be ready to work in workspace/sandbox.
Option 2: turn the bare into a working sandbox
If the local clone does not work, you can do the equivalent steps manually:
mkdir sandbox
cp -ar downloaded-bare.git sandbox/.git
cd sandbox
git init
and again, sandbox is now ready for normal work.
Recently master branch for Google repo tool has been updated to support Windows OS. It is clear from commit logs : https://gerrit.googlesource.com/git-repo/+log
I am able to run basic commands like repo init and repo sync using repo tool on Windows (which makes use of MinGW Git on Windows). In my work I need to create a local mirror of a repository and then use it. repo tool works fine to create mirror repository.
Here are commands used to create mirror repository on local drive on Windows OS.
$ repo.cmd init -u <URL> -b <branch_name> -m <manifest_file_name> --mirror --no-repo-verify
$ repo.cmd sync --no-tags
--no-repo-verify is used to forcefully use master branch of repo tool.
The above commands create the mirror in local drive C:\git-repo\test\mirror-testing\mirror
But when I refer the above mirror to sync in other drive then it shows error.
Command:
$ repo.cmd init -u <URL> -b <Branch_name> -m <manifest_file_name> --reference="C:\git-repo\test\mirror-testing\mirror" --no-repo-verify
Error:
error: object directory C:/git-repo/test/mirror-testing/mirror/project/manifest.git/objects? does not exist; check .git/objects/info/alternates.
The above command creates alternates file in C:/git-repo/test/mirror-testing/mirror/project/manifest.git/objects/info/ directory and that file contains below path:
C:\git-repo\test\mirror-testing\mirror\project/manifest.git\objects
I have tried other formats to provide reference value:
Git format: "/C/git-repo/test/mirror-testing/mirror"
Cygwin format: "/cygdrive/c/git-repo/test/mirror-testing/mirror"
Using above formats in reference does not create alternates file in objects directory.
repo init time in all above cases simply suggests that mirror is not referred and init is done from network.
When I repeat the same test with Cygwin Git + Google repo tool (stable branch) then I do not see any error and repo init time and sync time is very less compared to the mirror init and sync time, which simply suggests that mirror is referred.
repo.cmd is a batch file wrapper to invoke repo tool with python.
repo.cmd file contains single line
#call python %~dp0\repo %*
I am using Cygwin terminal in Windows 7 to run these commands.
To be clear repo init and repo sync shows error while referring to mirror but it completes successfully by syncing from outside network. The issue is that mirror is not referred.
Has anyone used Google repo on Windows for creating mirror and syncing in other drive using as reference?
I have tested Google repo tool master branch with MinGW Git on Windows 7 and Windows 10.
repo init and repo sync work on both OS.
Even creating the local mirror using --mirror is working, but referring that local mirror to sync in other drive does not work and displays error: "object directory not found".
To be clear using --reference with local mirror shows error, but it eventually uses the network and ignores the local mirror. Ultimately the command completes successfully, but it does not make the use of local mirror. I do not see any workaround for this on Windows for now.
Meanwhile Windows 10 supports Linux bash natively without using any VM.
WSL, the Windows Subsystem for Linux, is a free, optional feature of Windows 10 that allows Linux programs to run on Windows. It provides you with a Windows version of the bash shell and a compatibility layer that permits many Linux programs to run natively on your Windows machine. Using this option you can replace Cygwin Git with Linux Git.
I have tested repo tool on Linux Bash (with Ubuntu distribution installed) for repo init, sync, mirror and reference commands and it works. In fact we use Linux bash so simply Goole repo stable branch works, you do not need to use the master branch to make it work.
I have recently set up Vagrant on my machine, and the first thing I noticed was that my terminal config was not synced, when I sshed into my server.
For instance I have changed my shell from bash to zsh, which does a lot of beautiful things for me (like removing case-sensitive auto completion). But on my vagrant virtual machine, or on my server, all this cool stuff is now gone. Also stuff like my important aliases is not synced.
Now, what is a proper way to sync stuff like this?
EDIT:
So currently, when I create/remove/edit an alias on my local machine, I have to copy the exact same changes into my VM and all other servers I frequently use. I see this as a very time consuming and unnecessary task.
What I do is version control my dotfiles and I keep them on github. Dotfiles are just the files in your root that start with a dot in the name such as .bashrc or .zshrc. They are "invisible" files, so you have to use ls -a instead of just ls to see them.
Here are my dotfiles: https://github.com/aharris88/dotfiles
When I get on a new machine, I just clone the repository to ~/dotfiles
Then, I have a bash script in there called setup.sh that backs up any old dotfiles that might already be in root into ~/dotfiles_old. Then it creates symlinks to the files that are in ~/dotfiles.
It also installs zsh and oh-my-zsh if it isn't already. It should work for linux or mac os x.
Here is an article describing how to version control your dotfiles: http://blog.smalleycreative.com/tutorials/using-git-and-github-to-manage-your-dotfiles/
Another thing that I do to get a new mac ready is use kitchenplan: https://github.com/kitchenplan/kitchenplan, which can sync a lot more settings, but this probably isn't what you're asking about. Here is my kitchenplan config: https://github.com/aharris88/kitchenplan-config
I have a repo that has two branches, which i would like to work on simultaneously.
After some reading I found git has a script git-new-workdir.
Im trying run use the script from the git for windows bash but get the following error.
$ git-new-workdir
sh: git-new-workdir: command not found
How do I use this script on windows?
Due to some of the commands in the git-new-workdir functions not existing on windows, the script won't work.
I have found this windows port of the script. Works great for me.
https://github.com/joero74/git-new-workdir
Git 2.5 (Q2 2015) will replace contrib/workdir/git-new-workdir with an official native Git command which works on any OS (including Windows).
The release notes mentions:
does not rely on symbolic links and make sharing of objects and refs safer by making the borrowee and borrowers aware of each other.
That is because the multiple working trees are "linked", or actually recorded in the main repo new $GIT_DIR/worktrees folder.
See "Multiple working directories with Git?" for more.
On my installation, the script file is located in /usr/share/git/contrib/workdir/git-new-workdir.
Perhaps if it's not installed in that version of git, you can just download its raw form and run it with bash /path/to/git-new-workdir. At your preference you can also install it in /usr/local/bin changing permissions when necessary.
I have been struggling with this git problem.
The problem is that when I do a fresh clone from GitHub, git reports that some files has changed although I have not touched them.
Often this happens when I switch branches as well. If I go from an unmodified master to another branch and back to master, it says files has been changed in master.
I have been reading about line endings and tried just about everything in that category, but nothing seems to help.
The repository is https://github.com/seesharper/LightInject is case someone would like to try and see if they have the same problem.
A friend of mine had the exact same problem with the same repository on his Windows 8 machine. Then he tried it on Windows 7 and the problem went away.
Does anybody know of any issues with using git on windows 8.
I have also tried this on another Windows 8 machine and it has the same problem.
I've dealt with this issue in the past - keep in mind that most git installations run on non-windows servers. There's a distinct possibility that what Windows is seeing is actually something where the "filemode" of the file is different than what Linux expects, therefore it sees the file as changed.
Poking around on the internet, there may be a way to fix the filemode issue - but nothing on google is jogging my memory at the moment. I skimmed over this, maybe something in it will help?
https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/0EdNev3NNsw
I can't promise the above has a silver bullet for you, but it seems like there's good discussion about how Windows filemode messes up git indexes, sometimes.
I experienced the same issue with Windows 7. This is something I did to resolve (you might try):
git clone git#github.com:seesharper/LightInject.git
cd LightInject
git status
git checkout -f -b mine HEAD~
git status
git checkout master
git status
git branch -D mine