Beliebte Suchanfragen

Cloud Native

DevOps

IT-Security

Agile Methoden

Java

//

Use git! Even for small things.

24.9.2015 | 2 minutes of reading time

In my current project we have to use a code generator (crazy enough, I know). This code generator is a C# program. I use a MacBook Pro to do my daily work. That means I have to run a VM to use the generator. Annoying. Usually I wiggled my way around doing bigger things with it. When I had to use it, I usually did small things with it, like update some i18n. I could commit and push those changes directly to our central git repository and everything was fine.

Today I had to generate my first bigger code change. Some UI got changed, some entities got their fields removed but I dealt with it they way I was used to. Generate, commit, push. When I checked out the changes in my native system where I do the normal programming, all hell broke loose.

The changes I committed lead to lots of compilation errors. Our Jenkins was complaining and I went into stress mode. It took me two hours to identify the problems and fix them in a way that doesn’t break the code semantics (you don’t want to maintain generated unit tests).

After I restored order, I took a look into how my colleagues, who had generated more often than me, solved that problem. They shared a folder in their VM and copied the generated code around. I didn’t like that because I feel that I don’t have that much control over what happens.

So I did the following:

  1. I used a Windows share to make the generated folder available on my MacOS system. The path I got was:
    1/Volumes/name-of-vm/workspace/my-generated-code-repo
  2. I moved into my local copy of that repository and added that path as an extra remote:
    1git remote add vm /Volumes/name-of-vm/workspace/my-generated-code-repo
  3. Now after I generated code in the VM I could just commit it (in the VM of course):
    1git commit -m 'meaningful message'
  4. And then I could pull it into my native development environment:
    1git pull vm master
  5. Now I could take all the time I needed to correct eventual errors. After that I just pushed it to origin as usual:
    1git add . && git commit -m 'another meaningful message' && git push

What I wasn’t sure about before was what would happen If I now pull  the repository in my VM, but after I did just that it was totally clear to me. The VM commit I pulled into my native environment was – of course – already in the VM. Git is so smart to notice that and just pulls the commit I pushed from my IDE to origin.

Now I have a nice workflow with a commit after I generated new files and a second commit after I edited them.

If you read this and have other nice and/or unusual use cases for git, feel free to drop me a comment.

share post

Likes

0

//

Gemeinsam bessere Projekte umsetzen.

Wir helfen deinem Unternehmen.

Du stehst vor einer großen IT-Herausforderung? Wir sorgen für eine maßgeschneiderte Unterstützung. Informiere dich jetzt.

Hilf uns, noch besser zu werden.

Wir sind immer auf der Suche nach neuen Talenten. Auch für dich ist die passende Stelle dabei.