GIT




By  Colten Rouska
(Rizowski)

History


  • (2002) Linux kernel managed with BitKeeper
  • (2005) BitKeeper became unavailable and Git was born

About

Made For:

  • Speed
  • Simplicity
  • Fully distributed
  • Handle Large projects easily (Linux kernel)
  • Non-linear development (thousands of parallel branches)

Inner Workings

Which is Git and which is like other version control systems?

Inner Workings


  • Git doesn't keep track of file changes over time.
  • Keeps a snapshot (mini file system) and stores a reference

Inner Workings

Do you require an internet connection to use Git?
No. To clone and push a repository you may need an internet connection.

Where is the Git history stored  Server or Locally?
Git history  is stored on every device that has the Git repository. (Locally)

Distributed Workflows

Git has a complex branching system. With it you can have multiple types of workflows.

Staging Area



The space between a modified file and a commit

Creating a Repository


Initializing (Fresh start)
root@Machine ~/myRepo
$ git initInitialized empty Git repository in /home/myRepo/.git/

Cloning (Existing Repository)
root@Machine ~/myRepo$ git clone myUsername@MyAwesomeRepo/myAwesomeProject.git

Modifications

Default:
root@Machine ~/myRepo$ git status
# On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # modified file: File1.txt # new file: MyAwesomeFile.txt
Simplified:
$ git status -s  M  File1.txt  A  MyAwesomeFile.txt

Adding Files

Usage:
git add usage: git add [options] [--] <file-pattern>
Options:
-n, --dry-run          # run without executing and verbose results-p, --patch            # specify chunks of a file-A, --all              # add everything and skip stage
Wildcards:
$ git add *.sh
$ git add .

Committing

Short hand:
root@Machine ~/myRepo$ git commit -m "Some Message Here"

Long hand:
root@Machine ~/myRepo$ git commit
< Type your message here ># Please enter the commit message for your changes...# Changes will be committed: ...# ...~~

Patching Files

root@Machine ~/myRepo $ git add -p
Options:
y - Yes add this hunkn - No don't add this hunkd - No don't add and skip remaining hunkss - Split the hunk into smaller hunkse - Manually edit the hunk

Ammending

Commit message
$ git commit --amend -m "My new message"
Insert forgotten files
$ git commit --amend -C HEAD



Branching

Create
$ git branch <Branch Name>$ git checkout <Branch Name>
Create and Checkout
$ git checkout -b <Branch Name>
Push to Server
$ git push origin <Branch Name>
Push with hooks
$ git push -u <remote> <branch>

Rebasing

In what situation would you use these?

Rebasing from the remote repository:
$ git pull --rebase
Rebasing from master:
$ git rebase master

Bisect


$ git bisect start
$ git bisect bad
$ git bisect good [v1.0 ...]
$ git bisect reset
$ git bisect start HEAD v1.0
$ git bisect run bake       # Hopefully the list is short


Tools


Merge Tools
Git logs / Commit history

Merging

A monster on its own
$ git merge --commit / --no-commit / -m   # commit the merge or not for inspection--edit / -e                   # edit the auto generated merge message--strategy / -s <something>   # implement your own merging strategy--abort                       # revert merge if conflicts arise

Merge Tool

Kdiff3

Git History

$ git log
commit c63h23354nfgj3945hrjfgj4hb43bh345Author: Awesome Bub <Super@Duper.org>Date: Thu Feb 30 08:14:55 2014 -0700 My Commit Message. #Bug-958
commit ...

Gitk

$ gitk --[all] &--max-count=<number>--since=<date>--until=<date>

Generally Good Practices

  • Branch Prune Repeat
    • Major changes
    • Features
    • Experiments
  • Be granular with commits
    • Commit often
    • Be specific
  • Keep up to date with the project repository
    • The left behind sheep gets eaten

Questions?


Git

By Colten Rouska (Rizowski)

Git

A presentation on Git. What is it? Why is it the chosen VCS? How can you use it?

  • 986