On Github PeterEltgroth / GITitTogether
Lead Technical Analystpeter.eltgroth@so.mnscu.edu
Web Architectjeremy.heydman@so.mnscu.edu
A system that:
records changes over time allows you to revert versions does comparisons across time knows who changed what and when it was changedDesign goals:
Speed Simplicity (like other *nix tools) Support for non-linear development Fully distributed Able to handle large projects Short HistoryGit takes a stream snapshots by doing a SHA-1 check-sum of everything before it is committed.
If a file has not changed Git points to the previous version, this is a Directed Acyclyic GraphAnd later syncronize with others
Experiment with solutions, merge the best & delete the rest.
Changing branches applies the diff between the current & new branch in a single directory structureFast comparisons over the complete life of the project
Since Mavericks (10.9) just type 'git' in a terminal.
If you want/need a newer version downlaod it directly from git-scm, use Homebrew, or GitHub Desktop.
Download git for windows or GitHub Desktop.
Both provide a command line BASH emulation for git.Fedora:
$ sudo yum install git-all
Debian-based:
$ sudo apt-get install git-all
My favorite GUI
$ git {optional-command-name} --help
Learn Git commands in your browser at try.github.io
$ mkdir myproj
$ cd myproj
$ git initThe .git/ contains everything in one place.
$ git status
Short Status
$ git status -s
$ git add {file}
$ git add *.java
$ git add *1. Create a few files 2. git status (view untracked files) 3. git add 4. git status (untracked files are now staged)
Diff of modified changes
$ git diff
Diff of staged changes
$ git diff --staged1. Modify a committed file. 2. git status (see what has changed) 3. git diff (see the difference, how it changed) 4. git add (stage the changes file(s))
$ git reset {file-path}
$ git reset *.java
$ git reset *1. Modify a committed file. 2. git add (stage it) 3. git status (confirm that it is staged) 4. git reset (unstage a file) 5. git status (confirm that it is unstaged)
$ git commit -m '{message}'1. git status (confirm it has been committed) 2. git diff
Create
$ git branch {branch-name}
Delete
$ git branch -d {branch-name}
$ git checkout {branch-name}1. Add or modify a file and commit it 2. checkout master 3. create another branch, checkout, make a change, commit 4. git diff {b1} {b2}
$ git merge {branch-name}1. chekcout master and create a conflict 2. merge
$ git mergetool1. resolve conflict and save 2. exit merge tool 3. commit
Replay a changeset by rewinding to a common ancestor and reapplying each change in turn.
This keeps history more linear and easier to read.
$ git rebase {branch-name}
$ git checkout master
$ git merge experiment
Add
$ git tag -a 0.1.0 "Alpha release"
List All
$ git tag
List matching tags
$ git tag -l {search-string}
List all 1.2 tags
$ git tag -l "1.2*"
$ git log
Show diffs for the last n commits
$ git log -p -{n}
Show abbreviated stats
$ git log --stat
Show a graph
$ git log --graph
Your copy of a repository in at the hosting provider.
$ git clone {path to repo}
$ git clone https://github.com/PeterEltgroth/itconf2016Now you have a copy of the repository with the complete history.
List
$ git remote
List with URLs
$ git remote -v
Inspect
$ git remote show {optional-remote-name}By default origin is the location you cloned from, typically this will be your Fork.
Add
$ git remote add {remote-name} {url}
Rename
$ git remote rename {old-name} {new-name}
Remove
$ git remote rm {remote-name}How do we know if we're caught up to repository we forked from? git remote add upstream https://github.com/heydman/itconf2016
$ git fetch {remote-name}Fetch changes from a remote
Fetch & Merge the remote branch into the current branch
$ git pull {remote-name} {remote-branch}If there are conflicts, you will need to resolve them.
Push remote branch into the current branch
$ git push {remote-name} {branch-name}Create a branch, change something, commit it and push it to origin.
If your fork (or any other repo) already has your C4 commit and then you rebase locally, it WILL cause problems.
Sorry, this is a bit random, but lets flashback to rebasing for a moment.A request that a change you made be pulled back into a branch on another copy of the repository.
As a developer submitting a PR, it is generally your responsibility to catch up and resolve any merge conflicts with the branch your PR is targeting.
Created with reveal.js Source code located at: GITitTogether
Thank You!