Git Commands

So here are a list of git commands that I use a lot. I wanted to make a simple list with descriptions so that I can look back for future reference. Enjoy!

> git init

: Sets up the current working directory for git.

> git remote add origin {url}

: Sets up the current working directory repository based on the URL.

> git clone {url}

: Copies the repository into the current working directory under the a folder with the repository name.

> git pull origin {branch}

: Pulls the files from given branch of all revisions committed after your last pull.

> git checkout {branch}

: Moves to another pre-existing branch.

> git checkout -b {new_branch_name}

: Moves to a new branch with the given name.

> git branch

: View all available branches.

> git branch -m {old_branch_name} {new_branch_name}

: Renames a local branch.

> git branch [-d|-D] {branch}

: Deletes a local branch (-D = forced).

> git add {file}

: Adds the files to stage.

> git rm {file}

: Marks file for delete.

> git commit -m "message"

: Commits all the staged files locally (with a message).

> git push origin {branch}

: Pushes all saved commits to the server.

> git status

: View all the staged/un-staged files.

> git log

: View a list of the latest commits.

> git reset --hard HEAD

: Resets all the files to the last pulled commit.

> git reset --soft HEAD^

: Undo last commit.

> git checkout {file}

: Removes all local changes and resets the file.

(FYI: This post will be updated as I remember new commands to add)

How to Install SFML 2.0 into Ubuntu 12.04

So this tutorial will take you through the installation of SFML 2.0 into a freshly installed version of Ubuntu (12.04.2) using the latest snapshot available. I have taken a mix of these steps from the SFML website and SFML Coder’s website. If you would like further clarification on things I’ve said you can try to look at those tutorials.

So what is the snapshot? Well the snapshot is just the current working version of the source code of SFML 2.0. You can view the source code here if you’re interested. But just like any other program, in order to use it we need to build and run (aka install) it. Which I will explain more later.

Step 1: Download the required libraries/programs

First in the terminal we will need to download cmake and the cmake gui. This is what we will use for building the binaries.

> sudo apt-get install cmake
> sudo apt-get install cmake-qt-gui

After cmake is installed, we can now download the library dependencies for SFML 2.0 to work.

> sudo apt-get install g++
> sudo apt-get install libpthread-stubs0-dev
> sudo apt-get install libgl1-mesa-dev
> sudo apt-get install libx11-dev 
> sudo apt-get install libxrandr-dev
> sudo apt-get install libfreetype6-dev
> sudo apt-get install libglew1.5-dev
> sudo apt-get install libjpeg8-dev
> sudo apt-get install libgpgme11-dev
> sudo apt-get install libsndfile1-dev
> sudo apt-get install libopenal-dev

Lastly, if you want to download the documentation, you will need to install doxygen. Otherwise this step is not required.

> sudo apt-get install doxygen

Now we can download the snapshot and build the binaries!

Step 2: Download the latest snapshot

The latest snapshot of SFML 2.0 can be found at:

By clicking this link you will download a file with the name LaurentGomila-SFML-2.0-xxxxxxxx.tar.gz where the x’s relate to the latest commit made in github.

From here you just need to unpack the binaries:

> tar xvf LaurentGomila-SFML-2.0-xxxxxxxx.tar.gz

Lastly before actually starting cmake, I’m going to rename the binary folder (for simplification) and create a build folder in the same directory where the generated code will go:

> mv LaurentGomila-SFML-2.0-xxxxxxxx SFML2
> mkdir SFML2-build

Now we can use cmake to build the binaries.

Step 3: Build the binaries

In the command line (or just by searching for the application) open up the CMAKE GUI.

> cmake-gui

Now enter the paths to the binaries and the build folder into the window that pops up.

cmake1

Now press the ‘configure’ button and in the pop-up window just press the ‘Finish’ buton.

cmake2

Now the table in the middle will be populated and you can select whether or not you want to install the examples (SFML_BUILD_EXAMPLES) or the documentation (SFML_BUILD_DOC). I selected to install both as shown below:

cmake3

If you selected to install the documentation or examples you must reconfigure. Otherwise you can just press the ‘generate’ button.

After you are prompted that the generation is done you can close the cmake gui.

Step 4: Compiling and installing the binaries

So now you’re ready to compile and install the binaries. First navigate to the build folder directory.

> cd /path/to/SFML2-build

And compile the binaries using make:

> make

Once the files are all compiled, you now need to install them into the /usr/local/lib/ folder. The make file has a compile option that lets you do this easily:

> sudo make install

(sudo is required since you are managing the /usr directory.)

Lastly you to update the files that contain the paths to the libraries using:

> ldconfig

After this SFML 2.0 should now be installed! You can test this by running any of the example programs or by running the sample code from the SFML website.

How to Install Adobe Flash into Chromium

So whenever I do a fresh install of my Ubuntu, I always have an issue installing flash in chromium. I recently came across an easy way to do it, so I thought I would share :)

1. Download the latest tar.gz version of adobe flash player for Linux (http://get.adobe.com/flashplayer/)

2. Open up the terminal and extract the files:

> tar xvf flash_player_file_name.tar.gz

3. Copy the libflashplayer.so to the plugin folder for chromium:

> sudo cp libflashplayer.so /usr/lib/chromium-browser/plugins/

After this is done, restart chromium and flash should work!