Git version management today!

So, you’re working on a project for longer than a couple of days. Maybe you will even have to write up a report on the progress at the end (and don’t always remember to document what you’re doing). One thing you will strive to avoid is losing your data – because, let’s face it: even a week’s worth of work can put you at risk if you’re working on a deadline (if you don’t, it will still be annoying). Maybe you also want to experiment a little. You can always undo your changes manually but if you experiment takes longer than a day, you may not even remember all details.

My favourite solution to these problems is using remote version management. There are a couple of different systems I have had the pleasure (and displeasure) to work with over the past couple of years and so far, git has been my weapon of choice in the battle against data loss and chaos. My usual setup is to have a server where I store a so-called “bare” repository (i.e. a repository that does not contain a checked-out version of my files). This repository is usually placed on a server I can reach from anywhere I want. Setting it up is pretty easy:

$ mkdir myRepo.git
$ cd myRepo.git
$ git --bare init
Initialized empty Git repository in path/to/myRepo.git/

Now, I can clone the repository to any other computer I want.

$ git clone user@server:path/to/myRepo.git
Cloning into 'myRepo'...
[password prompt] 
warning: You appear to have cloned an empty repository.

If you have never used git on your computer, you need to set your name and email address. The easiest way to do this is to write the following into ~/.gitconfig:

  [user]
          name = Your Name
          email = Your Email

Now, you may add files into the repository. As a rule of thumb, you add everything that is raw data and omit generated files (pdf, executables, compilation byproducts, most hidden files). Below are some examples I use a lot.

$ git add *.h *.c *.hpp *.cpp      # C(++) source files
$ git add CMakeLists.txt           # build file
$ git add *.tex *.bib pics/*       # tex source files, pictures

Now it’s time to commit your first controlled version (imagine a commit as a snapshot of your files). This is mostly straightforward, but there’s one little trap: in later commits, you will have files that are already tracked which you have modified. To include them (if you simply want to commit all changes), make sure not to forget the little “-a”!

$ git commit            # will open an editor for your commit message
$ git commit -m "..."   # give the first commit message directly
$ git commit -a         # commit all changes, including modified files  !!!

You can also choose to commit specific changed files by adding these files to the commit explicitly (even if they are already tracked), and then committing without the “-a” option:

$ git add thisFile thatFile
$ git commit

Now you have a local version. However, if you work on more than one machine (or simply want to have a backup), you will have to “push” the changes to the server. Other systems (e.g. svn) do not need this extra step, however, their committing process requires an internet connection if you have a remote repository. With a commit+push system, you will be able to store versions on your computer while working on a train and simply push them to the server once you arrive at your destination.
On the first push, you will have to specify a branch to work in. Here, it’s called master, but you can also call it Uncle Scrooge, your name, a specific feature you’re working on, etc. Later, you automatically commit to the branch you’re currently checked into.

$ git push origin master   # first time pushing
$ git push                 # later

If you’ve been working from one computer and now want to get the most recent version on a different one, you will have to “pull” it from the server. (Before you do this, commit your changes.)

$ git pull

Congratulations, you can now use the basic functions of git!

Here are a couple of useful tools:

$ git help      # guess what
$ git status    # gives you a list of all files and their tracking 
                  status
$ git stash     # lets you temporarily stash away your changes (e.g. when you pull but don't want to commit yet)
$ git branch    # lets you work with several branches in parallel (recommended if you're not working alone!!)
$ git checkout  # lets you switch (or reset) to a specific commit or branch
$ git diff      # lets you view differences
$ git mv/rm     # same as mv/rm, just with repository support

Then, there is the .gitignore, a file that lets you keep certain files from being tracked. Why is this cool? If you have a bunch of new files, you can simply add all of them by writing

git add *

instead of adding each of them manually! You simply put a file called .gitignore in your myRepo folder and fill it. Here’s an example:

# compiled files
*.o
*.exe
*.pdf

# compressed files
*.tar
*.zip

# hidden files
*~
*.tmp
.*  

# cmake byproducts
CMakeFiles
CMakeCache.txt
cmake_install.cmake
Makefile

It makes sense to track the .gitignore if you use more than one computer. Since we just told git that we want to ignore .* files, you will have to force the adding process:

git add -f .gitignore

And that’s it! You have your git all set up. Have fun and don’t forget to commit regularly and push every once in a while. :)

Moline, which state?

Long story short: I just spent 10 weeks in California. This week, I’m at the IEEE Visweek in Atlanta, GA. My plan was to fly from San Francisco to Atlanta with a transfer in Denver. But then everything went wrong.

When I arrive at San Francisco airport on Saturday morning I find myself having trouble with the check-in machine. It refuses my passport and Miles&More card but ends up accepting my reservation number. Yes, I’m an adult, no I’m not travelling with an infant on my lap. One of my flights seems to be overbooked. No, I’m not interested in taking a different flight in exchange for a $200 voucher. I want an extra suitcase and pay for it. Then, the machine tells me to seek assistance by an agent. When I ask airline staff, they send my all the way across the checkin area to the agent checkin. There, I have to check in with the machine again (I haven’t changed my mind about the voucher); it wants me to pay for the additional suitcase again. Finally, an agent sees me, checks in my two suitcases and I end up with my tickets. What was so difficult in the first place? No idea. But this cost me enough time to have to hurry to my gate. Through the body scanner, no liquids, shoes off… same procedure as every time.

I catch the first flight, arrive in Denver and spend 2 out of my 3 hours having lunch and ice cream. I walk to my gate, double and triple check that I’m at the right place, and start my computer to send some comments on a dissertation to the friend who wrote it. from afar, I see a colleague from Hamburg talk to the agents and walk away and assume he just wanted to know if there’s enough time to grab some food.

When I want to board the plane, the ticket scanner refuses my ticket. I’m not on the list. Don’t worry, the lady reassures me. She takes my ticket (which clearly states my flight info) and checks me in manually. I’m lucky and get in a front row seat with lots of leg room. I nap through most of the flight. Then I hear the flight attendant announcing that we’re approaching Moline. Wait, what? Maybe she accidentally said the wrong name. Then, “Welcome to Moline.” Maybe the Atlanta airport has a name? I get off the plane, look at the clock, it’s 2 hours off my planned arrival time. A look at the arrivals screen outside security announces a flight from Atlanta arriving soon. The girl who sat next to me on the flight walks by with her parents (who picked her up) and the following dialogue unfolds

“Excuse me… where are we?”
“Moline.”
“Moline, which state?”
“Illinois.”

I don’t even know where Illinois is, so they tell me we’re 2 hours away from Chicago. I thank them (they wish me luck), freak out for a minute, then I head back to the gate to take care of my situation. The flight crew tells me I need to see an agent. The policeman (who followed me when I went back past security.. oops) kindly arranges a meeting for me.

The flight agent arranges flights for me in the morning (there’s a direct flight but I have to be on the same airline so I fly via Chicago) and a hotel for the night. I also get two breakfast vouchers for the airports. Turns out I don’t have to pay for this mess. Also, I’m told that my suitcases are already in Atlanta.

At the hotel (in Iowa), I shower, read and reply to some messages, and go to bed for a meagre 4 hours of sleep (possibly less, my body was still in the California timezone so I wasn’t very tired around midnight). At 4:30, I take the shuttle to the airport, at 6 I fly to Chicago.

My transfer time is quite short so I don’t waste too much time waiting. We board the plane (I get Economy Plus seating – yay!), and are then told to unboard again because something is wrong with the plane which needs to be fixed. Instead of the promised 2 minutes, we wait for 20 before we get back on the plane. I’m super tired and pass out before the plane takes off. When I wake up again, we’re already half way across the US.

In Atlanta, I go to the missing luggage counter, pick up my two suitcases and leave the airport within less than 30 minutes.

All this turned out pretty okay for me. I was 14 hours late (not bad considering the magnitude of that mess) and only missed 2 sessions of the conference. I also got to add two states to my visited states list (I once decided they count if I was outside the airport/car). However, I still don’t fully understand how all that could happen.

  • Why was there no big announcement for the gate change? I’m pretty sure I was alert enough to not miss that, and the screen clearly said Atlanta when I sat down.
  • Why didn’t they think to check if it’s the right flight if I’m not on the list and they know there was a gate change?
  • Why was I able to get on a flight I wasn’t supposed to be on?
  • How come they didn’t ask for me on the other flight? I’ve heard announcements asking for missing passengers very often, but my colleagues didn’t hear anything while they were waiting.
  • Why was my luggage able to travel to Atlanta when I wasn’t on the plane?

There’s a lot of security measures at the airport. After the two bodyscans I was put through, I got pat-downs on my ankle and the back pocket of my pants because they lit up. I had to take of my shoes. I wasn’t permitted to take liquids through security. But my luggage flew without me and I was able to board the wrong flight.
So much for all the safety measures.

Project #veganweek

Last week, I spontaneously participated in a vegan week with @kuraj, @jessie_ohki (and bf), @erynwen28 and a couple of others.

Why? tl;dr: Because I can.

As you may (or may not) know, I lived strictly vegetarian for about five to six years. More recently, I’ve been eating dead animal again, mostly because I was fed up with my food allergies AND being vegetarian making it hard to find nice stuff to eat. My main motivation behind #veganweek (besides trying out something new) was to see how much of a difference it makes in my diet, and how I cope with eating vegan.

Lessons I’ve learned:

  • Shopping vegan is… interesting. If you have a new food restriction, you usually spend the first couple of times shopping reading lots of labels and after a while, you know what you can eat and what you can’t. Been there, done that. But there are hardly any products which do not contain dairy products or eggs. The women at the cheese counter were very friendly and eager to help me when I asked for vegan cheese. (They also told me “We advertise not selling [Analogkäse].” when I explained that I don’t mean tofu.)
  • Coffee without milk isn’t quite as horrible as I thought. (It was work coffee though.)
  • Soy milk curdles when you pour it into coffee. It was even worse when I poured coffee into soy milk. Then I did some research. Apparently, there are two main issues: a) Temperature (soy milk curdles more quickly if it’s warm) and b) the coffee’s acidity (which causes the actual curdling). If anyone knows about proper scientific experiments on this – please tell me. ;)
    Also, vanilla soy milk also tastes pretty nice with work coffee.
  • Food labelling in Germany sucks. Vegan stuff is usually declared as vegetarian on the packaging, if at all. Have fun reading ingredient lists…
  • Induction without a sound step doesn’t work any better in real life than it does in mathematics. Just because all meat replacement products you’ve ever seen weren’t just vegetarian but also vegan, this doesn’t mean that all of them are.
  • Thinner/smaller waffles are nicer than having to clean up afterwards if you use too much dough. (Oops…)
  • Broken handmixers sound horrible.
  • Vegan waffle dough sticks better to the waffle iron than to itself, so you need more oil. Eggs really help here.
  • Too much soy makes me sick.
  • Vegan cheese is almost impossible to find in Kaiserslautern.
  • Dried tomatoes are really really salty.
  • My favourite curry recipe is actually vegan. :3
  • Being a vegetarian at the university Mensa is ok(ish), but being a vegan is really hard. The same thing goes for eating out in general. There are no vegetarian or vegan restaurants here, and even if you just meet some friends, most snacks you could nibble on aren’t vegan.
  • It probably gets easier once you get used to just carrying some food with you wherever you go.
  • Interestingly, people gave me a lot less shit about this project than I used to get for eating vegetarian. But then that may just be because they knew it was only temporary. Some were really supportive, too – @starlightCircus even surprised me with vegan muffins! ♥
    2013-01-08 20.37.26s

Stuff I’ve tried:

  • Vegan waffles. (OMG, so. damn. good.)
  • Soy yoghurt. I’ve always loved soy pudding (chocolate!! ♥), but I was very hesitant trying yoghurt because in my mind, soy and yoghurt didn’t mix well. However, I really liked it. (Now, that was only one kind, so I’ll have to try some more soon.)
  • Vegan cream cheese. We’re not going to be friends.
  • Coconut water with mango. Interesting but not really my thing (expected that much because I don’t like it fresh, either).

Stuff I wanted to try but didn’t:

  • Vegan cheese (slices). Didn’t find it.
  • Vegan feta. Found it but didn’t have much use for it right away. May do that during the barbecue season.
  • Vegan milk chocolate. Didn’t look for it.

What did I eat?

  • Monday: Lye pretzel, Pasta with Tomato Sauce (Mensa; no parmesan on top, and no salad or soup for me), pretzel sticks, soy yoghurt with mango, bread with salami and cream cheese alternatives (the first of which I had to find out is actually not vegan since the proteins come from eggs), tangerines.
  • Tuesday: Banana, bread with jelly, chocolate pudding, waffles, muffins, even more waffles.Waffles
  • Wednesday: Waffles, tangerine, Pasta Aglio e Olio with dried tomatoes, muffins.
  • Thursday: Chocolate pudding, tangerine, Wraps with Falafel and Veggies.
    Wrap with Falafel
  • Friday: Bread with sausage and cream cheese, tangerine, muffins, Chickpea Curry, banana, chocolate pudding.
    Chickpea Curry
  • Saturday: Banana, Best Fried Potatoes I’ve Ever Made (with dried tomatoes, rosemary, onions) and Salad with impromptu dressing (and I was so sure I had balsamic vinegar!!!), rolls, chocolate pudding, rice waffles with chocolate.
    Fried potatoes and salad
  • Sunday: Bread with sausage and cream cheese, Thai Curry, rice waffle with chocolate, some Indian food @Nirzaree made for me (veggies in a tomato sauce, and pan bread), chocolate.

Recipes

Waffles (German)
Chickpea Curry (German)

 

Where do I go from here?

This was a very interesting experience for me, and I would (will) certainly do this again. However, I really really missed chocolate (or at least some more variety) and cheese. What I didn’t miss at all: Meat. I expected that much since I never found it hard to be vegetarian from a psychological standpoint (it just sucks in some restaurants), and I’m considering going back to eating mostly or exclusively vegetarian.

I’d also prefer to buy dairy products and eggs from a place where I know the animals are treated well, so if you know something in (or very close to) Kaiserslautern, I’d love to hear about it!