Git workshop GDG Tlemcen

At some point of your development career, you will realize that git is not just a good skill to learn. But a must have for any developer.

I did this workshop in purpose of introducing Git to our Google Developer Group Tlemcen new members.

Here is what we covered so far:

  1. Brief Introduction of Git.
  2. Installing Git in different Operating Systems.
  3. Git Global configuration.
  4. Initializing repository.
  5. How to commit your changes.
  6. How to see and manage history.
  7. Branches.

What was not covered :

  1. Setting up your remote repository at (Github and Bitbucket) & (SSH Configuration)
  2. Issues
  3. Fork & Pull requests
  4. GUI Git clients.

What we need to get started

  • Terminal :black_medium_square:
  • Code Editor Atom or Sublime Text
  • Cup of coffee :coffee:

Let’s Get Started

First thing to do after installing Git instructions Here.

  • Git Global configuration:
$ git config --global user.email "youremail@example.com"
$ git config --global user.name "your name"
  • Initializing repository:

cd into you project folder. To initialize Git repository of your project just type the following command line:

$ cd project_folder
$ git init
#=> Initialized empty Git repository in project_folder/.git/
  • Commit changes:

For example i created a project folder named gittut initialize it and created an empty index.html file:

$ touch index.html

If you are using Windows you need to check Unix commands during Git Installation. For this command to work.

Then run this to get the list of the untracked files:

$ git status

You will get something like this:

center

As you can see Git already gives you some useful information. Telling you that there is an untracked file index.html and to do what is called Staging you need to run the following:

$ git add --all #=> This will stage all the untracked files.
$ git add index.html #=> This will stage only index.html

Staging a file is like taking a snapshot of it. To learn more about this concept Here

Now that we added our new file to the Staging Area we just run a commit so it can be saved permanently in .git/ directory.

$ git commit -m "My First commit" #=> With a messsage.
$ git commit  #=> This will take to Vim editor to enter your commit message.
  • Time travelling :sunglasses:

To see the history of your commits just run the following:

$ git log
#=> This will log all commits.

You will get something like this

center

$ git log --oneline
#=> This will log all commits, but in a short way.
$ git log -n 1 --oneline
#=> This will log one commit, in a short way.
$ git log -p index.html
#=> This will log all commits made, in index.html.

Please note that there is other combinations, for logging history Here

To be continued

Part II

A very special thanks for all the GDG Tlemcen Team. For giving me the opportunity to do this workshop.