This tutorial is about version control using Git. For this tutorial I will assume you are familiar with some kind of source control, for example SVN. We will skip the basics of how all source control works and just focus on working with Git in this case. The Git workflow is most commonly used for open source projects, because it's excellent for communication and coordination. In this tutorial, however, we're aiming to use Git for a private repository, and in order to achieve that you will need an account on Bitbucket. If you're a student, you can get some free private repositories on GitHub too!
Installing required software:
Git Extensions: The GUI we will use in this tutorial, Git Extensions, is the most suitable GUI for larger software projects, because it uses KDiff3 to solve conflicts (more on conflicts in the next part of the tutorial). If you work alone, or you know you will not bump in any file conflicting scenario's it's easier to download Github's GUI. This will not be covered in this tutorial, but it's fairly easy and straightforward to use once you know the basics of Git.
Git Extensions has its own version of Git included, if you want the newest Git, you can download it here: Git for windows. This installs the basic source control management.
Setting up a repository:
If you are joining an already existing project you can skip this step! Just make sure you are invited to the project (if it was a private one) and that you can reach the actual repository.
Once you log in to your account on Bitbucked you will see your dashboard and from there click the Create or Create repository button. You will see a screen like this:
Here you will have to name your project and choose which kind of source control you are going to use, in this case it will be Git. The Access level is automatically set to private, which means (at first) only you can reach this repository, which is desired. You can also choose to have Issue tracking which is basically a neat function to report bugs and couple them to this repository. The Wiki option allows you to create documentation for the current repository. Finally there are some language specific options which will set you up with some basics for the programming language in your repository.
Once you have done this, you're done setting up your repository and it's time to clone it and get started.
Cloning an existing project:
From here on, we will use the Git Extensions GUI. The first time you start Git Extensions you will probably have to fill in some personal information like your username. After that you will arrive at your Dashboard, which will most probably be empty. Listed among the Common Actions, or alternatively in the Start menu, you will find the "Clone Repository" option. You will see something like this (I already filled it in):
The "Repository to Clone" is the project you want to create a local copy of (or a local directory you want to create a Git Repository of). The rest of the options are about where you want to locate this repository on your PC. The rest of the options (should) be automatically set as seen above. You can find the link to your repository on Bitbucket by going to your repository page and clicking "Clone". Copy&Paste the HTTPS into Git Extensions as I did in the picture and make sure to remove the "git clone" commands at the start (these are done automatically for you by Git Extensions).
Important: If you get the error "fatal: could not read Password for" etc. You will need to run the following command in the Git Bash (Tools -> Git Bash, or Ctrl + G):git config --global core.askpass /usr/libexec/git-core/git-gui--askpass
This will re-enable the notification which asks you to fill in your password instead of directly declining your request.
Making your first Commit and Pushing it to the repository:
If you followed the steps above you will be in your currently empty repository in Git Extensions, looking at the following screen:
Click the "Edit .gitignore" button which will open a new window with a text editor. For now, just click the "Add default ignores" and save the file. This file will tell Git which files should be ignored on each commit so they won't bother showing up on staging each commit. After you've done that, click the "Commit" button, which will open the staging window. Select your newly made .gitignore file and press the "Stage" button with the purple arrow pointing down. By doing this you want to commit only the .gitignore file and nothing else, which is what we want.
To finish this tutorial, enter some commit message and press the "Commit & Push" button which will stage the file to commit and push it to the remote repository on Bitbucket (which you can see on Bitbucket itself if you click on source).
This was the first part of the tutorial showing you how to set up your private repository using Bitbucket. In the next part I will show you the power of Git by using branches and solving file conflicts on commits.
Continue to part 2