What git ?

this git !


"I'm an egotistical bastard, 
and I name all my projects after myself. 
First 'Linux', now 'git'."

WHAT is git ?


/ɡɪt/ is a distributed version control and source code management (SCM) system with an emphasis on speed.

AND...

there are lots of cute cats...


WHy GIT ?



WHY GIT ?


Branching and Merging
Git is fast
Git is distributed
Many possible workflows
Data Assurance
Choice of private or public
And much more...

BRANCHING & MERGING


Frictionless Context Switching
Role-Based Codelines
Feature Based Workflow
Disposable Experimentation

In most version control systems, 
branching is easy, merging is usually hard
git is different !

GIT IS FAST


I mean, like SERIOUSLY fast...



(but the real speed comes from flexible workflows)

GIT IS DISTRIBUTED


Many backups

Any workflow

MANY POSSIBLE WORKFLOWS


Pick the workflow that suits your project, not the one that suits your version control system.

https://www.atlassian.com/git/workflows

DATA ASSURANCE

"The data model that Git uses ensures the cryptographic integrity of every bit of your project. Every file and commit is checksummed and retrieved by its checksum when checked back out. It's impossible to get anything out of Git other than the exact bits you put in."

+ you usually have MANY backups...

PRIVATE OR PUBLIC



CHOICE OR DE-FACTO







how do i....

get started ?


Download for windows

Download for Mac OS X

Download for Linux

configure git ?


$ git config --global user.name "Your Name Here"
# Sets the default name for git to use when you commit

$ git config --global user.email "your_email@example.com"
# Sets the default email for git to use when you commit


You can also set up your SSH keys

create a new repository ?


create a new directory, open it and perform a 
git init
to create a new git repository.

checkout a repository ?


create a working copy of a local repository by running the command
git clone /path/to/repository
when using a remote server, your command will be
git clone username@host:/path/to/repository

GROK THE workflow ?


your local repository consists of three "trees" maintained by git. the first one is your Working Directory which holds the actual files. the second one is the Index which acts as a staging area and finally theHEAD which points to the last commit you've made.


add & commit stuff ?


You can propose changes (add it to the Index) using
git add <filename>
git add *
This is the first step in the basic git workflow. To actually commit these changes use
git commit -m "Commit message"
Now the file is committed to the HEAD, but not in your remote repository yet.

push changes ?


Your changes are now in the HEAD of your local working copy. To send those changes to your remote repository, execute 
git push origin main
Change main to whatever branch you want to push your changes to. 

If you have not cloned an existing repository and want to connect your repository to a remote server, you need to add it with
git remote add origin <server>
Now you are able to push your changes to the selected remote server

JUST CHECKING...



make branches ?


Branches are used to develop features isolated from each other. The main branch is the "default" branch when you create a repository. 
Use other branches for development and merge them back to the main branch upon completion.


make branches ?

create a new branch named "feature_x" and switch to it:
git checkout -b feature_x

switch back to main:
git checkout main

delete the branch again:
git branch -d feature_x

Note: a branch is not available to other users unless you push the branch to your remote repository:
git push origin <branch>

update & merge ?

to update your local repository to the newest commit on origin: 
git pull
in your working directory to fetch and merge remote changes.
to merge another branch into your active branch (e.g. master), use
git merge <branch>
in both cases git tries to auto-merge changes. Unfortunately, this is not always possible and results in conflicts. You are responsible to merge those conflicts manually by editing the files shown by git. After changing, you need to mark them as merged with
git add <filename>
before merging changes, you can also preview them by using
git diff <source_branch> <target_branch>

tag stuff ?


it's recommended to create tags for software releases. this is a known concept, which also exists in SVN. You can create a new tag named 1.0.0by executing
git tag 1.0.0 1b2e1d63ff
the 1b2e1d63ff stands for the first 10 characters of the commit id you want to reference with your tag. You can get the commit id with 
git log
you can also use fewer characters of the commit id, it just has to be unique.

WHAT IF I MAKE A MISTAKE ?



replace local changes ?


In case you did something wrong (which really never happens ;) you can replace local changes using the command
git checkout -- <filename>
this replaces the changes in your working tree with the last content in HEAD. Changes already added to the index, as well as new files, will be kept. If you instead want to drop all your local changes and commits, fetch the latest history from the server and point your local main branch at it like this

git fetch origin
git reset --hard origin/main

wait, wTF HAPPENED ?




RESOURCES to the rescue !


Getting Git Right:
https://www.atlassian.com/git

Git Reference:
https://git-scm.com/docs

Read all about it and become a pro:
https://git-scm.com/book


AH, OK

You may

ACTUALLY...


That's pretty much it !


Questions ?

WELCOME TO THE DARK SIDE...



Made with Slides.com