Skip to content

Latest commit

 

History

History
276 lines (201 loc) · 4.56 KB

git.md

File metadata and controls

276 lines (201 loc) · 4.56 KB

git


managing code we've already written


(how to make sure we don't lose them)

NOTES: TADA! No notes, really

=====

Your Daily Tasks

  • Create things
  • Save things
  • Edit things
  • Save the thing again

=====

Many Developers <=> One Code

NOTES:

  • Common problem when working on a project
  • 2 or more people working on the same file

///// world_domination.py

import dominator

dominator.dominate(scope='world')
dominator.evil_laugh('ha-ha-ha')

/////

world_domination.py.old
world_domination.py.older
world_domination.py.oldest
world_domination.py.december_25_1993

daines_world_domination.py
connies_world_domination.py

=====

Enter VCS (Version Control Systems)!

CVS (Concurrent Version System)
SVN (Subversion)
GIT ( *just* git)

NOTES: Centralized Version Control Systems

=====

What is git?

Distributed version control system

=====

History

Created by Linus Torvalds for the linux kernel around 2005

Replaces the proprietary DVCS used for maintaining the linux kernel

NOTES: BitKeeper is a proprietary Distributed VCS, which the linux development community was able to use for free.

=====

What's special about git?

Limited downtime
Everyone has the complete history
Everything is done offline
No central authority
Changes can be shared without a server

===== Used at companies such as:

  • Google
  • Netflix
  • Facebook
  • Microsoft
  • IBM

=====

What is a repository?

NOTES: Repository is where all the code is saved, code history NOT the current running code, but just a directory where people copy the code from

===== Centralized VCS SVN vs GIT diagram

///// Distributed VCS
Distributed VCS

=====

Git basics

Getting started

///// ##Snapshots Snapshot

///// ##Snapshots Snapshot

/////

Nearly every operation is local

NOTES:

  • No latency overhead
  • Uses your PC's computing power to calculate and show the difference in snapshots from months or years ago

/////

Git has integrity

SHA-1 hashing NOTES: Everything is check-summed (hashed) before it is stored It is impossible to change anything without git knowing about it

/////

Git only adds data*

*you can lose data, but only if you really mess things up

/////

Git has three states

  • Working directory (Local)
  • Staging
  • .git repository (Pushed)

=====

How do I start using git?

(https://git-scm.com/) Initialize git on your current project

git init

///// NOTE: It is important to initialize git on the highest folder in your directory structure

+--dwglib
|  +--daine_utils
|  +--common_utils
+--another_lib

Please init git on dwglib instead of daine_utils or common_utils

+--dwglib
|  +--.git/
|  +--daine_utils
|  +--common_utils
+--another_lib

=====

Three Stages

Stages

/////

Lifecycle of your file

(recording changes) Lifecycle

NOTES: Git is a way to keep your files organized /////

Checking on your files

git status

/////

Tracking / saving new files

git add

/////

Ignoring files

.gitignore

/////

Viewing your staged and unstaged changes

/////

Committing your changes

git commit

/////

Skipping the staging area

not recommended

/////

Moving & renaming files

# Rename myoldfile.py to mynewfile.py
git rm myoldfile.py
git add mynewfile.py

``` git mv myoldfile.py mynewfile.py ```

=====

Commit History

git log

=====

Source Tree

///// ///// ///// ///// ![](images/git staged.PNG) ///// ![](images/git pre-commit.PNG) ///// ![](images/git log.PNG) ///// ///// ![](images/git commit changes.PNG)