Working with Git – For Orbital – whoami



Working with Git – For Orbital – whoami

5 1


Orbital-Git-Workshop


On Github laurenceputra / Orbital-Git-Workshop

Working with Git

For Orbital

How to get started, and what you need to get going

by Laurence Putra

Slides can be found at http://bit.ly/orbitalgit

whoami

Recently graduated geek

Engineer at BillPin

Organiser at GeekcampSG

Heads and contributes to a bunch of other user groups

Experience with Git

3 years

Moved a company to Git

Still have tons to learn

What you'll be learning today

What can Git do?

How do you fit it into your workflow

Live Exercise with Git

What is Git?

Before we answer that ...

Who here plays computer games?

(Angry birds not counted)

Git works like your checkpoint system in computer games

Have checkpoints along the way

And when you do something really stupid

Go back to your saved game and resume

No more trying to figure out what you edited

Why Git?

Yea, I get the whole idea about Git, but I can simply name my files
  • app-v1-0.py
  • app-v1-1.py
  • app.v2-0.py
and sync it using Sugarsync (or Dropbox) to the rest of my team.

Yea, you can do that

But as you join bigger teams in future (bigger projects or work), how do you keep track what changes are made in what files?

Or who release v2-0?

And will v2-1 contain the updates from v2-0?

Setting up

Who here hasn't set up?

Install Git http://git-scm.com/downloads

Connecting to Github http://bit.ly/orbitalgitssh

Create a repo on Github too.

Windows specific

  • Use Git Bash only
  • Checkout Windows-style, commit Unix-style line endings

Basic config

Windows users open git bash

Mac and Linux users open terminal

Type in these 2 lines

git config --global user.name "John Doe"
git config --global user.email johndoe@example.com

Functionalities of Git

clone add commit push pull status checkout

Overview

git clone

Copies an existing repository onto your machine

git clone git@github.com:laurenceputra/Orbital-Git-Workshop.git

git status

Tells you what changes have been made to your repository

git add

Adds files you have changed to the changes that need to be staged

git add index.html

OR

git add -A

git commit

Commits your changes to your own machine

git commit

OR

git commit -m "This is the commit message"

git push

Pushes the changes to another server

git push

yea, that's it

git pull

Gets changes your teammates make

git pull

Assuming John and Peter pull the same stuff from yesterday, and now John updates the code.

Peter has made changes to the code as well, and cannot push.

Peter has to do a

git pull

which will merge the code in automatically

merging

In case of conflicts (computer unable to decide how to merge)

>>>>
stuff
<<<<

Commit after you have manually merged it

Try to not have more than 1 person edit the same line to prevent such problems from happening

git checkout

Retrieve the old checkpointed file you did something stupid to

git checkout folder1/*.c
git checkout folder1/app.py

Best Practices

Meaningful commit messages

Recap, how to commit?

git commit -m "message"

Bad commit messages

stuff
It works!
You should have trusted me. 
Committed some changes
ALL SORTS OF THINGS
This is a basic implementation that works. 

More bad examples over at http://whatthecommit.com/

Commit frequency

How often should you commit?

Every new feature

When they are working!

Others

Look up branching if you have time

Read up more about Git as you use it more

Learn to RTFM

When all fails...

I'll be around

Useful readings

Branching

The Git Book

The End

If you ever are looking for a job in future, drop me an email. I'm almost always hiring, either for the company I'm working for, or for someone else. You can contact me somehow at GeekSphere.net