Personal Life

One post, three WTF?

This post will be short:

Ikea Malkolm Chair First WTF: i bought an Ikea Chair, and the pieces to build it came inside the back. Interesting…

Second WTF: This article appeared on my local newspaper, title says “Nella lite spunta la motosega”. Giving a very rough translation of the article: two car nearly had an accident, the guys on them started a babble and one guy pulled out a chainsaw. That happened near (approx 15km) from my place. Now I really think this is a safe place.

Clock Third and biggest WTF: As my (two or three) readers will probably know, I live in Italy, a country build where the huge Roman Empire was. Thought we didn’t inherit anything good (arts excluded) from that glorious empire, we sometimes still use roman numbers, usually in clocks. The clock in the photo is the one I bought for my new home and I liked it really much, until I realized about a number: the four. I almost had an heart attack when I saw it. How could people build a clock ith a four written like IIII instead of IV???

PC Nerding

Git, Unity3D and Dropbox

Sometimes I think I look a bit obsessed by revision control, but i really find those notes are the only ones worth writing down.
My previous tutorial about Git and Unity3D used a virtual machine for keeping git repos, setting up correctly a VM is hard stuff for some, so i decided to make an easier tutorial on the matter.
Today I will show you how to store a git repository right in your Dropbox folder.

Step 1: Creating a bare remote repository in your Dropbox folder
First, using git bash let’s navigate to our Dropbox folder. This location may vary depending on your configuration.

cd ~/Documents/Dropbox

Once we are here, we’ll make a new folder and create a new bare repo inside it.

mkdir myGitProject
cd myGitproject
git --bare init

Step 2: Setting Unity3D
If you are not using Unity3D or if you followed my previous Git and Unity3D tutorial, you can skip to step 3.
In Unity3D editor, create or load a project, then go to Project-Settings>Editor and under Version Control>Mode select Meta Files. Save your scene/project.

Open your explorer and navigate to your Unity3D project root folder. NOTE: your project root folder is the one which contains Assets, Library and ProjectSettings folders. Create a new file called .gitignore (be sure to include the dot), open it in Notepad or your app choice and paste this block inside it. This file will tell git to ignore those files, since those are not needed when syncing.


#Project/User Preference Files

#OS Junk

Step 3: Create the local repository
Open your git bash again and navigate to your project folder


Then start a new local repo using

git init

Add all the needed files to your git repo using (the unneeded files are automatically discarded by out .gitignore list)

git add -A

And lastly make the first commit

git commit -m “Initial commit”

Step 4: Link your local and remote repo
Keeping the bash open in our local project folder, let’s link the remote dropbox repo by using:

git remote add origin ~/Documents/Dropbox/myGitProject

Now let’s make a push to the remote repo

git push origin master

If you are working alone, you’re done. If you want to sync across different computers keep reading.

Step 5: Cloning and pushing from another pc
Now on your second pc / other dev pc clone the remote repo
NOTE: in the first line i set my working folder to home folder, you should set a folder where you usually store your projects like ~/Documents/Unity or ~/Projects

cd ~
git clone ~/Dropbox/myGitProject myLocalClone

Now play around and modify some stuff and code.
To push back stuff, add them to a local commit and push them like we did earlier.

cd ~/myLocalClone
git commit myscript.cs -m 'modified a file'
git push origin master

Step 6: Pulling
Now on our first pc we can get the changes made on the second one by pulling stuff

cd ~\Documents\Unity\myLocalProject
git pull origin master

Now you are set. Remember to push/pull/merge stuff on all synced computers.

Final Notes
While it will work well with small projects by small teams, I would not recommend using it with big files or more than 2-3 developers. This because the entire git repo is shared over Dropbox and two git pushes at the same time will cause Dropbox to sync those pushes together, messing up your project data.
This is a basic setup, for anything more professional like a real git repo server, issue tracking and wiki functions you should look at BitBucket, which offers free unlimited (private or public) repository hosting for small teams (up to five devs).

Q. Can I use other backup services?
A. Google Drive, Asus WebStorage and other similar services should work the same way. Remember to not push stuff from different location at the same time.

Q. Will this tutorial work with non Unity3D projects?
A. I suppose yes, just skip Step 2 and it should work fine.

Q. Most tutorials out there use the command git add . to add files where you used git add -A. Why is that?
A. I prefer using git add -A because it indexes removed files, while git add . doesn’t. A good explanation about those differences is explained in this StackOverflow question. I think most tutorials use git add . because indexing deleted files (with -A) is completely useless before the first commit.

Q. Do you actually use this setup?
A. Sometimes yes, for tiny projects and for projects where I always need a ‘local’ remote repo where there’s no internet connection available.

Q. Is it safe to push/pull to/from repo while Unity3D’s editor is open?
A. No. To avoid errors, you should always push and pull stuff with your editor closed.

Q. OMG! My project lost all the linkages set in the unity inspector!!!!11111ONEONEONE
A. That’s probably because you forgot to enable meta files in your project settings. See Step 2.

Q. Why do you store a repo inside dropbox? It is not better to store my project folder straigth into Dropbox?
A. Dropbox will always try to sync saved files, even those you are still working on. The main difference in my approach is that you can edit all the files you need and commit your modification only when you are sure whether these are working. This will avoid other synced devs to get not working or incomplete files.

PC Nerding

A new tablet: ASUS TF300T

I used to hate the new generation of smartphones and tablets (both iOS and Android). For example two or three years ago I bought an HTC Desire with Android 2.3, I used it for a couple month, then i threw it in a drawer and I kept using my old Nokia N95. You know, I was one of the guys who use telephones only for calls and sms, nothing else. But when i got my hands on this device I fell in love. I don’t know why, but i got a strange feeling while toying with it. Is it a new step into my nerdiest dream, indie game development? Probably yes, I got an basic Unity Android license in April and this is a great device to play and develop on.