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.

No comments: