Getting ready

Again, we'll use the example of the hello world repository. Make a fresh clone of the repository, or reset the master branch if you have already cloned one.

We can create the fresh clone as follows:

$ git clone https://github.com/PacktPublishing/Git-Version-Control-Cookbook-Second-Edition_hello_world_cookbook.git$ cd Git-Version-Control-Cookbook-Second-Edition_hello_world_cookbook

We can reset the existing clone as follows:

$ git checkout master $ git reset --hard origin/master HEAD is now at 3061dc6 Adds Java version of 'hello world'

We'll also need to have some files in the working condition, so we'll change hello_world.c to the following:

#include <stdio.h> 
void say_hello(void) { 
  printf("hello, worldn"); 
} 

int main(void){ ...

Get Git Version Control Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.