

¡Hola, soy Jorge!
"Hoy aprendo Git con @jotarios_ #HackSpace"


¿Qué veremos?
- El blob
y tree: los fundamentos de Git - ¿Qué es Git?
- Main stages and states: Modified, staged, Committed
- Git setup: System, Global, Local config
- Git basics: status, add, commit, push, pull, etc
- Branching model: branch, checkout


Download for free: https://git-scm.com/book/en/v2

Authors:
Scott Chacon,
Ben Straub
$ git init
Initialized empty Git repository in {PATH}/.git/
Initialize a new Git repository
$ tree .git

.git
├── branches
├── config
├── description
├── HEAD
├── hooks
│ ├── applypatch-msg.sample
│ ├── commit-msg.sample
│ ├── ...
│ ├── pre-receive.sample
│ └── update.sample
├── info
│ └── exclude
├── objects
│ ├── info
│ └── pack
└── refs
├── heads
└── tags


$ vim testing_blob.py
What is a Git object?
# file: testing_blob.py
print("Hello world from Git")
$ git hash-object -w testing_blob.py
5eefe3945ef60476ef9a4f37f4f3d653ef2316fe

.git
├── branches
├── config
├── description
├── HEAD
├── hooks
│ ├── applypatch-msg.sample
│ ├── commit-msg.sample
| ├── ...
│ ├── pre-receive.sample
│ └── update.sample
├── info
│ └── exclude
├── objects
│ ├── 5e
│ │ └── efe3945ef60476ef9a4f37f4f3d653ef2316fe
│ ├── info
│ └── pack
└── refs
├── heads
└── tags

$ git cat-file -p 5eefe3945ef60476ef9a4f37f4f3d653ef2316fe
print("Hello world from Git")
$ git cat-file -t 5eefe3945ef60476ef9a4f37f4f3d653ef2316fe
blob
Discovering the git object
Retrieving the content
What is Git?
"Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency".

definition taken from https://git-scm.com/

Control Version System
Did you...
controlled the versions using the filename?
my_awesome_project.zip
my_awesome_project2.zip
my_awesome_project_final_version.zip
my_not_awesome_project.zip
my_awesome_este_si_es.zip
my_awesome_rosita_de_guadalupe.zip

Control Version System
Did you...
wanna see a before version of you project?
BUT, YOU CAN'T!

Control Version System
Did you...
lost files and didn't have backup?

Control Version System
Did you...
share your project using Email, Drive, Whatsapp, etc?

Control Version System
- Versioning
- Code History
- Team collaboration
- You can see who messed things up
What is Git?
"A content-addresable filesystem, a simple key-value data store"

- From Scott and Ben
Main stages
working directory, index, working branch


Your project
Working directory/area
index
staging area
Your branch
Working branch
? ? ?
? ? ?
committed
modified
staged
Your file is...
You are in...

Let's go!
# Local (or project) scope
$ git config user.name “Jorge Rios”
$ git config user.email “jrios@bevertec.com”
# Global scope
$ git config --global user.name “Jorge Rios”
$ git config --global user.email “jrios@bevertec.com”
$ git config --list

Our first repository
$ git init
Initialized empty Git repository in {PATH}/.git/
$ git add --all
$ git commit -m "Add the next text"
$ git status

Your project
Working directory/area
index
staging area
Your branch
Working branch
git add
You are in...
git commit

Your project
Working directory/area
index
staging area
Your branch
Working branch
git add
You are in...
git commit
origin/master
origin
Remote repository
git push

Your project
Working directory/area
index
staging area
Your branch
Working branch
You are in...
origin/master
origin
Remote repository
git pull
More porcelain commands
$ git diff
$ git commit -- {file}
See my changes
Unmodifying a modified file in the working directory
$ git reset HEAD -- {file}
Revert staged changes

Branching model


Branching model
$ git checkout -b feature/blizzard-logo
$ git checkout feature/blizzard-logo
$ git branch -d feature/blizzard-logo
Create a new branch
Use a branch
Delete a branch
GitHub
Student Developer Pack

Get for free from https://education.github.com/pack
References
- Pro Git (2014) S. Chacon, B. Straub. Retrieved from https://git-scm.com/book/en/v2
- I Git It 101 - Cristian Llanos from @FandangoLat
GIT
By Jorge Rios
GIT
- 246