5 minute Git crash course

Well, this should be my first “real” post here.

The aim is to get started using Git on Windows in a real project within critical amount of time.

Disclaimer:This is my personal point of view and I am not arguing that what you read here is the best approach. Those are the steps that helped me personally start using Git as a source control system (SCS) in a real project.

Git is console/ command driven and TortoiseGit is a Git GUI for Windows. It will surely help you if you have no clue of Git commands (since you are reading this, I guess that would be the case). Default options for both programs should work just fine.

Create a new repository or connect to an existing one:

a) New one: right click your project folder and choose “Git Create repository here…”, OK
Right click on the project folder and select “TortoiseGit – Settings” and then “Git – Remote” and enter the URL of your remote Git installation

b) Connect to existing repository: right click on the folder under which the files will exist, select “Git Clone…” and enter the URL of the repository

Now you should have a working repository and the steps bellow are something that you will be using daily.

Start using it:

Get the latest version of the files:

In case you are not the only one to modify files in the repository, this step needs to be performed frequently in order to be sure that you have all the latest changes.

Right click on the project folder (or anywhere inside it) and select “Git Sync…” followed by “Pull”

What can go wrong: If you have edited a file and that same file was edited by someone else, you will receive an error message saying that “a conflict was detected” and you will need to either “stash” your changes or “commit” them. (See bellow)

Stash your changes:

By selecting “Stash save” you are adding all the changes between last commit to the stack of changes that could be reapplied at any moment. This will return the working directory to the clean state of the latest commit.

Stash Pop:

This one will return back latest saved “Stash” (set of changes).

Commit:

“Git Commit -> master” will pack your changes and add them to the master branch. It will give you an option to add a comment and select which file to include in the commit.

Push:

In order to have the changes uploaded to the remote repository you will need to do “Git Sync…” and then “Push”.

Revert:

This option will show a list with all the files that have been modified since the last commit. You will have a chance to compare them to their unmodified state or revert to it.

Switch/Checkout…

This is the command used for switching to another branch. It will fail in case there are changes made since last commit. In that case you will need to either revert, stash or commit the changes.

So far this should be enough to get you started in no time. However I would recommend to search online for a more comprehensive guide and give it a try when time permits.