Link Search Menu Expand Document

Git Guide

Git is a free version control system (VCS), used by programmers to keep track of the different versions of the files composing a software. Some basic understanding of how it works is needed, in order to make changes to the source code of the VideoLAN projects and contribute those changes back.

This page attempts to give a brief introduction and some useful tips about Git, but it can’t give you a full guide on how to use Git (especially if you’ve never used a VCS before) or be a complete reference. You can check out the following useful references if you are unfamiliar with Git:

Basic usage

First, you need to check out the source code from the VideoLAN Git using the git clone command. Depending for which project you want to obtain the source code, the address will be different. Below is an example for how to checkout the VLC development sources:

$ git clone https://git.videolan.org/git/vlc.git

Voilà! The full VLC source code and version history should be on your hard disk in the vlc folder.

Configure Git

When contributing to VLC and other VideoLAN projects, you should make sure you have your correct name and e-mail address set. In case you have not configured them yet, you can do so with:

$ git config --global user.name "Your Name"
$ git config --global user.email "me@example.com"

Alternatively if you only want to set those for the current repository, for example because you want just your VLC commits to use your work e-mail, just omit the --global flag.

Additionally there are some useful git aliases you can configure, which make some common git tasks easier:

Tip: Setting up git up

If you want to be able to just keep in sync using git up use:

$ git config --global alias.up "pull --rebase"

And if you like your tree to be messy and don’t want git to complain (like with SVN) use:

$ git config --global alias.up '!sh -c "git commit -a -m "Before rebase" && git pull --rebase && git reset head^"'

Tip: Setting up git wu

If you want to see what you are about to git push you can set up the wup (Git, what’s up?) alias for that:

$ git config --global alias.wu "log --stat origin..@{0}"

Tip: Setting up git wup

This is quite similar to git wu, but additionally it shows the diff along with the commits.

$ git config --global alias.wup "log -p origin..@{0}"

Quick fixes

Sometimes, when you just want to make a small change, like fix a typo or so, it might not be worth it to create a branch for it. In that case just work on the master branch and commit your changes. Once there are changes on the remote, you can easily rebase using:

$ git pull --rebase

Or, if you configured the up alias mentioned above, just:

$ git up

Working on a feature/bugfix

Let’s say now you want to work on a new feature or fix a bug you found. The best way to do that is to first create a local branch for that:

$ git checkout -b add-foo-codec

Now do your work on the newly created branch. If meanwhile there were more changes made on the remote, you might need to rebase your branch:

$ git fetch origin
$ git rebase origin/master