Saturday, April 30, 2016

Git for Windows Users with Git GUI

In my previous post i've set up a git server. In this post I will focus on Windows and git from a never-used-before standpoint. How to use git is not part of this series but there are some good YouTube videos where you can learn the basics

Git GUI
Since my users are typical Windows users that like to point and click in a GUI I went for Git GUI which can be found at https://git-for-windows.github.io/

After the installation some configuration needs to be done before you can start using it.

Setting up your local repository
To set up your local copy of the repository we need to create a directory. When you right click in your window you have in the shell menu the Git Gui Here option you should click.




This opens the Git GUI window where you can choose "Create New Repository". It will ask you to select a directory to create the repository.

Choose "browse" and click immediately "select folder". This will select the folder you just created to create you repository in.

Click "Create" and this will create the git repository for you. A new Git GUI window will open up.






Coupling the remote repository to the local repository






The first action is to chose the remote server, so we do Ctrl+A. This will pop up a new window asking you for the name of the repository and the location.

The name of the powershell repository I created in the previous post was "powershell" and the location was "bob@server.com:/export/git/powershell".

A prompt appears for bob's password and the data is fetched from the repository.







Working with the local repository
When you are satisfied with your work you open up the Git GUI for the local repository and then you need to "stage all the changed files to commit" (Ctrl-I).


 Next you add your commit message, on the quality of commit messages can be written books but the same principles of good communication always apply.

Finally you hit the commit button to commit it to the local repository and if you are happy with the end result you push it to the server. This last step will pop up a new window which is pretty straight forward.

Fetching changes from the server
The idea of git is of course to work together on projects thus our last step is to explain how you get the changes from others to your local repository.

The first step is to go into remote, and select fetch from powershell, our repository.












You will be prompted for your password. This fetches the data from the remote repository and thus all the changes. The next step is to merge the changes with the data you already have in your repository.













The merge will show you what has changed since your last synchronization and then you are good to go.

Conclusions
It is not that hard to work with git but it takes the discipline to synchronize your repositories. When you develop new features it is of course recommended to make branches and merge these but that is beyond the scope of this very basic tutorial.

Thursday, April 21, 2016

My pet is a hacker

I've got a pet and it is a bright and intelligent creature. In the past it caused some buffer overflows because walking over the keyboard was a direct way to get my attention but today my Windows session was locked and it decided that it would walk over my keyboard again.

It managed to hit the right shift key for more then 8 seconds and then enter. This resulted in my keyboard making noises ... a sound for every keystroke. Driving you crazy when you have a long passphrase instead of an 8 character password.

To undo it I had to hit the right shift key for 8 seconds again and hit enter. A nice little practical joke but I am sure if I would pull this off in an office during lunch hour some people will go crazy.

Tuesday, April 19, 2016

Setting up an internal git server

This is a blogpost to explain how you set up an internal git server on an Ubuntu server the quick and dirty way for a small team.

Setting up the server
Setting up the users
The first thing is to set up all the users. This is done with useradd. In our example our user is named bob

sudo useradd -d /home/bob -s /bin/bash bob

In my case the users already existed. If they do not exist you still need to provide each user with a password using passwd.

sudo passwd bob

Setting up the group who can read and write to the repository server
To make management simple we are going to group all our users in a group and then manage the access on a group level.

sudo addgroup git_users

Adding the users to a group
Next we need to add the users to the group git_users.

sudo usermod -a -G git_users bob

Creating the folder structure
Next we are going to create our repositories.

cd /
sudo mkdir -p /export/git/

Creation of the actual repositories will be done later in the setup.

Setting the ownership
The ownership is still set to root who is configuring the server so we still need to set it to the git_users group so that the users have access.

sudo chgrp git_users /export/git

Set read-write permissions and a sticky bit
Our git_users group needs read and write permissions so they can get to the repositories and write to them. We will use a sticky bit to make sure all objects underneath inherit all the read-write permissions.

sudo chmod g+rws /export/git

Set up our first repository
Our first repository we set up is to manage Powershell scripts.

sudo mkdir /export/git/powershell

To check if our inheritance was correct you can do

ls -la /export/git/powershell

You should see the group have read, write and a sticky bit.

Initializing our repositories
The final step on the server is to initialize the git repository. We use for this two options. The first option is to indicate it is a new repository and is named bare. The second option we use is called shared to indicate it is shared by the whole group.

cd /export/git/powershell
sudo git init --shared --bare

Everything is ready to be used the next step is to use the repositories.

In my next blogpost I will explain how to use Git GUI on Windows system.